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.1.3.tar.gz
(2.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arconfig-0.1.3.tar.gz.
File metadata
- Download URL: arconfig-0.1.3.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63a818eb197df28e67873525daa268489fade99222ceaa7d97fa5f924665593a
|
|
| MD5 |
6f79a4b3ab71f31e803574b4adc6b207
|
|
| BLAKE2b-256 |
2c7489b197f50f84eded04cbb212ba52d5b4bc2aa72a63f482b14bb3ef9b5da4
|
File details
Details for the file arconfig-0.1.3-py3-none-any.whl.
File metadata
- Download URL: arconfig-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28d651472c6903ac17644701f6fbc232a6350a35949ddf75aa5a3257aab5ee4a
|
|
| MD5 |
c0e46a5874184e9df7775544c73592ec
|
|
| BLAKE2b-256 |
e8373d22da8221fc5425ef8045d7e4a7e88e77b4fc8f96d9970cc9495496d6cb
|