Load configurations from a variety of configuration files and use them easily
Project description
Load configurations from a variety of configuration files and use them easily
Examples
Load configuration file if it exists
import configloaders
username = 'username'
password = 'password'
phone = 123456789
auto_login = True
configloaders.load_json(globals())
Load the configuration and update it on exit
import configloaders
username = 'username'
password = 'password'
phone = 123456789
auto_login = True
configloaders.load_json(globals(), save_on_exit=True)
Load the configuration and require the configuration file to exist
import configloaders
username = 'username'
password = 'password'
phone = 123456789
auto_login = True
configloaders.load_json(globals(), required=True)
Manually save the configuration
import configloaders
username = 'username'
password = 'password'
phone = 123456789
auto_login = True
configloaders.load_json(globals()).dump()
configloaders.load_json(globals()).dump(original=True)
configloaders.dump()
configloaders.dump(original=True)
Take all configuration items as command line arguments
import configloaders
username = 'username'
password = 'password'
phone = 123456789
auto_login = True
configloaders.load_argparse(globals())
# or
import argparse
parser = argparse.ArgumentParser()
configloaders.load_argparse(globals(), parser)
parser.parse_args()
Features
- Variables of the module type and those prefixed with "__" are ignored
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
configloaders-0.4.8.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for configloaders-0.4.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 538c1e79a2a1f85fae8ed7138e9cc33dcbb6785c220476d5ee68c32b82267650 |
|
MD5 | d5b4e17c2671a0d0e7a4b0ad409ee091 |
|
BLAKE2b-256 | 56c691991c9f30f51d578506424aca241ec73483f940e6c1a7da0a59a098f2f2 |