argunparse is intended to perform approximate reverse of argparse
Project description
Reversed argparse: generate string of command-line args from Python objects.
The argunparse is intended to perform an approximate reverse of what argparse does. In short: generating string (or a list of strings) of command-line arguments from a dict and/or a list.
how to use
Simple example of how argunparse works:
import argunparse
options = {
'v': True,
'long-flag': True,
'ignored': False,
'also-ignored': None,
'o': 'out_file.txt',
'log': 'log_file.txt'
}
args = {
'in_file.txt'
}
unparser = argunparse.ArgumentUnparser()
print(unparser.unparse(*args, **options))
# -v --long-flag -o=out_file.txt --log=log_file.txt in_file.txt
print(unparser.unparse_to_list(*args, **options))
# ['-v', '--long-flag', '-o=out_file.txt', '--log=log_file.txt', 'in_file.txt']
Special option values are:
True
– option will be treated as a flag;False
andNone
– option will be ignored.
All other values will be converted to strings using str()
.
For more examples see examples.ipynb notebook.
requirements
Python version 3.5 or later.
No other runtime dependencies.
However, building and running tests requires packages listed in test_requirements.txt.
Tested on Linux, OS X and Windows.
installation
For simplest installation use pip
:
pip3 install argunparse
links
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
Hashes for argunparse-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e24f8e922f293e5c1f4ee2558534c3c706d8fdb13744f498700aa4c3a7175fe0 |
|
MD5 | 287042c5a745406e4c3fec2e80bf1153 |
|
BLAKE2b-256 | 32913c84c050c15fe5d2aae16800c91c9a16a4f82de99c6e090f39ce4358d92b |