Skip to main content

global configparser object to be used across modules

Project description

pypi versions license

globconf

  • Creates a global configparser object, regardless of the project and module in need of it
  • A docker container can be used to host protected config files, consumable by the parser object
  • verify_required_options merges default options with the configparser ones, and optionally ENV options while validating required options have been set either way.

Getting Started

In a project using globconf:

from globconf import config, verify_required_options, read_config, fetch_config
# when starting the app, the config can be loaded from a specific path:
read_config(path='flaf.ini', force=True)  # reloads config, even if it already is loaded

# or from the globconfd container - caching supported as convenience for offline devs:
fetch_config('http://127.0.0.1:5000/cfg.ini', 'user', 'pass', cache_timeout=86400, force=True)

# if config is not explicitly loaded, config.ini is read from current folder (if there).

# verify_required_options checks presence of options, yielding a dict with the merged options 
# for the section
DEFAULTS = {'required': None, 'optional_a': 1234}
cfg = verify_required_options('Some section', ['required', 'options', 'for', 'the', 'section'])
 
# beyond this, its still basic ConfigParser as you know it..

In modules:

from globconf import verify_required_options
class cls(object):
    def __init__(self):
        self.cfg = verify_required_options('service now', ['host', 'user', 'pwd'])
        if self.cfg.get('verify_ssl', True) is False:
            import urllib3
            urllib3.disable_warnings(InsecureRequestWarning)

And your module is happy as long as someone has initialised the needed section in the global config.

globconfd via docker

docker run -it -v ./users.conf:env_users.conf -v ./cfgs:/configs -p 5000:5000 ssch/globconfd:latest -d

Prerequisites

configparser, diskcache, requests

Building

Build:

sudo python setup.py sdist bdist_wheel
twine upload dist/*

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Nahh..

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

globconf-0.0.7.tar.gz (8.1 kB view hashes)

Uploaded source

Built Distribution

globconf-0.0.7-py3-none-any.whl (9.5 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page