csparpa / pyowm

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

Configuration values should be injected when instantiating library entry point #8

Closed csparpa closed 10 years ago

csparpa commented 10 years ago

When executing:

>>> from pyowm import OWM
>>> owm = OWM('apikey', '2.5')

the library loads the configuration options found into the configurationXX.py relative to the OWM API version which is used (in this case, version 2.5).

The loading of this module is wired into the code, and this is bad. We want the configuration module's Python path to be injectable while instantiating the library main entry point, something like this:

>>> owm = OWM('apikey', '2.5', 'package.subpackage.my_configmodule' )

The user-provided config module shall be visible in the PYTHONPATH scope. Of course, proper fallback default values shall be provided for config options that are not correctly set / can't be found into the user-provided module.

This might be the chance to revisit the main OWM factory interface - in view of a next major release

csparpa commented 10 years ago

Fully implemented with commit e93aeae45a598c4fcef474ba8c9e1b8e751a5ce1 No default values will be provided... "we are all consenting adults!" (Kenneth Reitz) and therefore users shall write well-formed external config modules