Reversed argparse: generate string of command-line args from Python objects.
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.8 or later.
Python libraries as specified in requirements.txt.
Building and running tests additionally requires packages listed in requirements_test.txt.
Tested on Linux, macOS 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
File details
Details for the file argunparse-0.1.4.tar.gz
.
File metadata
- Download URL: argunparse-0.1.4.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d98668d381a8feff5229e5598a8272a9fa7400427576d1b1f1a8b5ff170acf |
|
MD5 | cc0242d346297f975c7491082c938cea |
|
BLAKE2b-256 | 8b25fb83e36339cfee4a6783b676ed4111b71edaf082b13b5eccd0222b01db86 |
File details
Details for the file argunparse-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: argunparse-0.1.4-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3866a7832984e800e24bdf7f63df35017fb8f16c852f757df9f1958bda168e54 |
|
MD5 | aa0aa279db864948aee53ae1f2606c81 |
|
BLAKE2b-256 | c359f27e516808c7922e590ce97377956f4badeb7511e9ededafd58f159f48aa |