Load and gen configuration for argparse
Project description
Save/Load your options to/into config
>>> from arconfig import GenConfigAction, LoadConfigAction >>> parser = argparse.ArgumentParser() >>> parser.add_argument("--config", action=LoadConfigAction) # add it before another options >>> parser.add_argument("--gen-config", action=GenConfigAction) >>> parser.add_argument('-s', action='store', dest='simple_value', help='Store a simple value') >>> parser.add_argument('-c', action='store_const', dest='constant_value', const='value-to-store', help='Store a constant value') >>> parser.add_argument('-t', action='store_true', default=False, dest='boolean_switch', help='Set a switch to true') >>> parser.add_argument('-f', action='store_false', default=False, dest='boolean_switch', help='Set a switch to false')
Generate simple config:
$ python script.py --gen-config { "simple_value": null, "constant_value": null, "config": null, "boolean_switch": false }
And load it:
$ python argparse_config.py --gen-config > /tmp/test.json $ python argparse_config.py --config=/tmp/test.json { "simple_value": null, "constant_value": null, "config": null, "gen_config": false, "boolean_switch": false }
All another arguments overwrite the config values (but counter are added).
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
arconfig-0.0.3.tar.gz
(2.4 kB
view details)
Built Distribution
File details
Details for the file arconfig-0.0.3.tar.gz
.
File metadata
- Download URL: arconfig-0.0.3.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 478fb2eae86d5196db1cc06af6caba11d2e555350ab2472f804a0688e3d12cb2 |
|
MD5 | c9500abb4312431978fb3bac526706e3 |
|
BLAKE2b-256 | 3c9ac4b8fad9274af1d688f224909b8656635c2412c2c326f608c9b4b27182b6 |
File details
Details for the file arconfig-0.0.3.macosx-10.10-intel.tar.gz
.
File metadata
- Download URL: arconfig-0.0.3.macosx-10.10-intel.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d211aa4c425178323e6844af936b4647baaf1cc041c68575f3e78775d0be1568 |
|
MD5 | c0823f67ed4e58254bc553ed068589b6 |
|
BLAKE2b-256 | b97d276684582e5fd796cf42f117d06c48248da4bba347eb6fa756c43fb64931 |