Skip to main content

Configuration made easy: JSON, encrypted, envvars, etc.

Project description

Build Status Dependency Updates Coverage Status Version Status

Configuration doesn’t get any easier than this …

pip install jsonconfig-tool

What’s it Used For?

  • Managing settings, configuration information, application data, etc.

  • Managing secrets, tokens, keys, passwords, etc.

  • Managing environment settings.

Basic Example

with Config('myapp') as cfg:
    cfg.data = 'Any JSON serializable object ...'
    cfg.pwd.a_secret = 'Encrypted data ...'
    cfg.env.a_variable = 'Environment variables.'

Additional Examples can be found in the documentation [1].

Simply Sane

No magic here

Configuration File Locations

Click [2] is the package used to determine the default application directory.

The default behavior is to return whatever is most appropriate for the operating system. To give you an idea, an app called Foo Bar would likely return the following:

Mac OS X:
~/Library/Application Support/Foo Bar

Mac OS X (POSIX):
~/.foo-bar

Unix:
~/.config/foo-bar

Unix (POSIX):
~/.foo-bar

Win XP (roaming):
C:\Documents and Settings\<user>\Local Settings\Application Data\Foo Bar

Win XP (not roaming):
C:\Documents and Settings\<user>\Application Data\Foo Bar

Win 7+ (roaming):
C:\Users\<user>\AppData\Roaming\Foo Bar

Win 7+ (not roaming):
C:\Users\<user>\AppData\Local\Foo Bar

Of course, you or the user are free to override this behavior and set the location to wherever you want.

Encryption Backends

Keyring [3] is the package used to manage encryption.

The default behavior is to select the most secure backend supported by the user’s platform. To give you an idea, the following Keyring backends would likely be returned:

Mac OS X:

Keychain [5]

Unix (with secretstorage installed):

Secret Service [6]

Unix (with dbus installed):

kwallet [7]

Windows:

Windows Credential Locker [8]

Of course, you or the user are free to override the defaults. The user can also change their Keyring backend preferences system-wide from the command-line or via configuration files. JSON Config will then use the user’s preferred Keyring backend unless told otherwise.

How Do You Want Your Data Served?

Box [4] is the package used to handle the data access wrappers.

PLAIN

No wrapping. Organic, free-ranging data. If it’s JSON serializable we’ll work with it. This is the default.

BOXED

Delivers your data in a Box [4]; a Python dictionary that supports both recursive dot notation access and standard dictionary key access. If you have a fear of being boxed-in, don’t panic! You can get in and out of the box at anytime, see the data conversion section below.

FROZEN

Ices the data in a Frozen Box, same as BOXED except immutable; will also be hashable if all objects in it are immutable.

NESTED

Nests the data in a default dictionary that can automatically create missing intermediary keys. It’s also very forgiving when retrieving data from the dictionary; for example, it won’t throw an error if a key doesn’t exist. Instead, it’ll return None; even if the key’s nested and multiple keys are missing.

Data Conversion

  • BOXED, FROZEN and NESTED are all subclasses of dicts or defaultdicts. You can convert back-and-forth between any of them at any time.

  • The objects listed above are Mappings, if your data object is not a Mapping then use PLAIN to free yourself of all of the trappings. With PLAIN it’s just you and your buddy Python; we get out of the way.

JSON Config Frees You to Do What You Do Best

Spend more time solving real-world problems, less time coding, testing & troubleshooting configuration issues.

References

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

jsonconfig-tool-1.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jsonconfig_tool-1.3-py2.py3-none-any.whl (8.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file jsonconfig-tool-1.3.tar.gz.

File metadata

  • Download URL: jsonconfig-tool-1.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsonconfig-tool-1.3.tar.gz
Algorithm Hash digest
SHA256 cc05fdbd7a0f9b624a3f7326597f1817acec1056ed9f29a5fdf3e5d9c6c10b61
MD5 8c41c5b49bb768b174bda301e0e28ef0
BLAKE2b-256 e8fea9849061d1312bf9c02375e115742b255bdf00e98abfda61d6403391713c

See more details on using hashes here.

File details

Details for the file jsonconfig_tool-1.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for jsonconfig_tool-1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c54bd76b21d312b6005d5110f97f73a6cb0e4600a1ef9772c288096736ab4385
MD5 d88f7cfe6e35906e5a5da3aa774a7131
BLAKE2b-256 83e2ab5be0207df6a46c760a87396873213dd768b9f7aedb475b643226d1eedc

See more details on using hashes here.

Supported by

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