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.5.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for configloaders-0.4.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a76612ad41c9d073be9c803c8483b4070183f224ac2efa4aaf07080b8dfa48 |
|
MD5 | ea0b0eeff3376fe1b7282f41d8d72af3 |
|
BLAKE2b-256 | b39e3caf04cad12e70f4b25367990406db71e75d54b957bffbad71fc728e2292 |