Skip to main content

Arconfig

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).

Metadata

Release files for arconfig 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arconfig 0.1.3
File Size Uploaded
arconfig-0.1.3.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for arconfig 0.1.3
File Interpreter ABI Platform
arconfig-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / arconfig-0.1.3.tar.gz

Download URL arconfig-0.1.3.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
63a818eb197df28e67873525daa268489fade99222ceaa7d97fa5f924665593a
BLAKE2b-256 checksum
How to use checksums
2c7489b197f50f84eded04cbb212ba52d5b4bc2aa72a63f482b14bb3ef9b5da4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / arconfig-0.1.3-py3-none-any.whl

Download URL arconfig-0.1.3-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28d651472c6903ac17644701f6fbc232a6350a35949ddf75aa5a3257aab5ee4a
BLAKE2b-256 checksum
How to use checksums
e8373d22da8221fc5425ef8045d7e4a7e88e77b4fc8f96d9970cc9495496d6cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page