def __init__(self, timeout=API_AVAILABILITY_TIMEOUT, cache=None,
              use_ssl=False, verify_ssl_certs=VERIFY_SSL_CERTS):
     self.timeout = timeout
     if cache is None:
         self.cache = nullcache.NullCache()
     else:
         self.cache = cache
     self.use_ssl = use_ssl
     self.verify_ssl_certs = verify_ssl_certs
Example #2
0
 def __init__(self,
              parsers,
              API_key=None,
              cache=nullcache.NullCache(),
              language="en"):
     self._parsers = parsers
     if API_key is not None:
         OWM25._assert_is_string("API_key", API_key)
     self._API_key = API_key
     self._httpclient = owmhttpclient.OWMHTTPClient(API_key, cache)
     self._language = language
Example #3
0
 def __init__(self,
              parsers,
              API_key=None,
              cache=nullcache.NullCache(),
              language="en"):
     self._parsers = parsers
     if API_key is not None:
         assert type(API_key) is str, "If provided, 'API_key' must be a str"
     self._API_key = API_key
     self._httpclient = owmhttpclient.OWMHTTPClient(API_key, cache)
     self._language = language
Example #4
0
 def __init__(self, parsers, API_key=None, cache=nullcache.NullCache(),
              language="en", subscription_type='free'):
     self._parsers = parsers
     if API_key is not None:
         OWM25._assert_is_string("API_key", API_key)
     self._API_key = API_key
     self._httpclient = owmhttpclient.OWMHTTPClient(API_key, cache,
                                                    subscription_type)
     self._language = language
     if API_key is None and subscription_type == 'pro':
         raise AssertionError('You must provide an API Key for paid subscriptions')
     self._subscription_type = subscription_type
Example #5
0
# Parser objects injection for OWM web API responses parsing
parsers = {
    'observation': observationparser.ObservationParser(),
    'observation_list': observationlistparser.ObservationListParser(),
    'forecast': forecastparser.ForecastParser(),
    'weather_history': weatherhistoryparser.WeatherHistoryParser(),
    'station_history': stationhistoryparser.StationHistoryParser(),
    'station': stationparser.StationParser(),
    'station_list': stationlistparser.StationListParser(),
}

# City ID registry
city_id_registry = cityidregistry.CityIDRegistry('cityids/%03d-%03d.txt')

# Cache provider to be used
cache = nullcache.NullCache()

# Default language for OWM web API queries text results
language = 'en'

# Default API subscription type ('free' or 'pro')
API_SUBSCRIPTION_TYPE = 'free'

# OWM web API availability test timeout in seconds
API_AVAILABILITY_TIMEOUT = 2

# Weather status code registry
weather_code_registry = weathercoderegistry.WeatherCodeRegistry({
    "rain": [{
        "start": 500,
        "end": 531