55
66from datapoint .Site import Site
77from datapoint .regions .region_names import REGION_NAMES
8-
98REGIONS_BASE_URL = 'http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/json'
109
10+
1111class RegionManager (object ):
1212 '''
13- Datapoint Manager for national and regional text forecasts
13+ Datapoint Manager for national and regional text forecasts
1414 '''
1515 def __init__ (self , api_key , base_url = None ):
1616 self .api_key = api_key
@@ -30,18 +30,18 @@ def call_api(self, path, **kwargs):
3030 '''
3131 if 'key' not in kwargs :
3232 kwargs ['key' ] = self .api_key
33- req = requests .get ('{}{ }' .format (self .base_url , path ), params = kwargs )
34-
33+ req = requests .get ('{0}{1 }' .format (self .base_url , path ), params = kwargs )
34+
3535 if req .status_code != requests .codes .ok :
3636 req .raise_for_status ()
3737
3838 return req .json ()
3939
4040 def get_all_regions (self ):
4141 '''
42- Request a list of regions from Datapoint. Returns each Region
43- as a Site object. Regions rarely change, so we cache the response
44- for one hour to minimise requests to API.
42+ Request a list of regions from Datapoint. Returns each Region
43+ as a Site object. Regions rarely change, so we cache the response
44+ for one hour to minimise requests to API.
4545 '''
4646 if (time () - self .regions_last_update ) < self .regions_update_time :
4747 return self .regions_last_request
@@ -63,4 +63,4 @@ def get_raw_forecast(self, region_id):
6363 '''
6464 Request unformatted forecast for a specific region_id.
6565 '''
66- return self .call_api ('/{}' .format (region_id ))
66+ return self .call_api ('/{0 }' .format (region_id ))
0 commit comments