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 module(object):
    def __init__(self):
        sec = 'service now'
        self.cfg = verify_required_options(sec, ['host', 'user', 'pwd'])
        if not self.cfg.getboolean('verify_ssl', fallback=True):
            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.6.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

globconf-0.0.6-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file globconf-0.0.6.tar.gz.

File metadata

  • Download URL: globconf-0.0.6.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

File hashes

Hashes for globconf-0.0.6.tar.gz
Algorithm Hash digest
SHA256 919a9c7dd82537c01502ab8addd0a710eb0ad30735b28dbe268ab5cc09c3f6dd
MD5 502d0f596f7541400d74c0bbd2568646
BLAKE2b-256 a5a55c7a5afcdc712f101004e9d24b2807fe09ecd7e21ef2e9419bebf6c854be

See more details on using hashes here.

File details

Details for the file globconf-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: globconf-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

File hashes

Hashes for globconf-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 c314f9f8fc6aec60ab857a3e256f5963d3fa294bae6fbc1c8aa0644beda81406
MD5 11e6857f510dab7c6ffeb0905f4746ba
BLAKE2b-256 7df5033e50f45a3f15c66954571c942cf41863461addfd846afb9ff28529c19d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page