Skip to main content

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


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)

Uploaded Source

Built Distribution

configloaders-0.4.8-py3-none-any.whl (12.0 kB view hashes)

Uploaded Python 3

Supported by

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