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.9.tar.gz
(6.9 kB
view hashes)
Built Distribution
Close
Hashes for configloaders-0.4.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be5704e41b15838889e433845cf51296e50f144256da86ec86da84fc6761719d |
|
MD5 | 65bc7bc0a32aefabd11470ec5dc1ce36 |
|
BLAKE2b-256 | 8c385f3b6f2181c29f3732a34de2f40764992bc07a875490a0d085898ecbc214 |