csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
789 stars 171 forks source link

PyOWM config as a dict #248

Closed csparpa closed 5 years ago

csparpa commented 6 years ago

New interface for injecting config into the main PyOWM entry point.

Requirements

The config dict can be provided either:

The config file are JSON based

Each OWM API (weather API, pollution API, etc..) has its own configuration section in the global config dict

TODOs

This is the logic format for the config dict:

GLOBAL
  - default language
  - default API subscription type
CONNECTION
  - use ssl (boolean)
  - verify SSL certs (boolean)
  - default connection timeout
CITY ID REGISTRY
  - pattern of city ID files (es. 'cityids/%03d-%03d.txt.gz')

Example of config load

Something like:

from pyowm import OWM, load_config_from
config_dict = load_config_from('/path/to/config.py')
owm = OWM('your-api-key', config_dict)