Application configuration engine
Project description
Python helper class to ingest and serialize app-specific configuration
Provides a self-contained (no dependencies outside the standard library), Python 2 and 3 compatible configuration manager. Automatically saves and restores your application’s configuration in your user home directory. Uses JSON for serialization. Supports dict-like methods and access semantics.
Installation
If your package does not permit dependency management, you can copy the Config class directly into your application from https://github.com/kislyuk/tweak/blob/master/tweak/__init__.py. Otherwise:
pip install tweak
Synopsis
from tweak import Config
config = Config()
config.host, config.port = "example.com", 9000
config.nested_config = {}
config.nested_config.foo = True
After restarting your application:
config = Config() print(config) >>> {'host': 'example.com', 'port': 9000, 'nested_config': {'foo': True}}
Using an argparse.Namespace object returned by argparse.parse_args():
parser = argparse.ArgumentParser() ... args = parser.parse_args() if args.foo is not None: config.foo = args.foo elif "foo" not in config: raise Exception("foo unconfigured") config.update(vars(args))
Links
Bugs
Please report bugs, issues, feature requests, etc. on GitHub.
License
Licensed under the terms of the Apache License, Version 2.0.
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
Built Distribution
File details
Details for the file tweak-0.0.2.tar.gz
.
File metadata
- Download URL: tweak-0.0.2.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7187c0ed4185166386aa51e2a19746d7263e12506cae52def9df294f34904850 |
|
MD5 | a158a2364610c23ef20715121055b7b9 |
|
BLAKE2b-256 | d6262065e7d6b67102f459852c5b893baa3f165678c16f5005dfe4944bc510e5 |
File details
Details for the file tweak-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: tweak-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7593403ae323490eea77c25f40e25a8e42c505591454ec08d34dda871190baa6 |
|
MD5 | bcf665ac807704e12bfdfafb4ea0d7a5 |
|
BLAKE2b-256 | 890d65cdbf08276166c66a55c3a5c68796a81bd724cc3bded188030fecbb452a |