argparsethis
A drop-in replacement to Python's built-in argparse, that provides the capability to argparse any arbitrary string, not just command line arguments. Is sourced from https://github.com/python/cpython/blob/3.8/Lib/argparse.py.
Installation
pip[3] install argparsethis
Usage
When creating your ArguementParser, just override the parameter input_list as a list of strings to parse. We recommend using shlex to split any raw strings into a list correctly. If input_list is not overridden, it will use standard command line arguments like normal. Also adds the exit_on_error parameter, if you want to raise an ArgumentException in the event of a parsing error or printing out the help, instead of just exiting (the default behavior).
import shlex
import argparsethis as argparse
# Argument parsing which outputs a dictionary.
def parse_args(input_str):
#Setup the argparser and all args
input_list = shlex.split(input_str)
parser = argparse.ArgumentParser(input_list = input_list, exit_on_error = False)
parser.add_argument("-q", "--quiet", help="suppress extra output", action="store_true", default=False)
return parser.parse_args()
argv1 = parse_args("test -h")
argv2 = parse_args("test -q")
if not argv2.quiet:
print("LOUD NOISES")
else:
print("Please be quiet")
Metadata
Release files for argparsethis 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| argparsethis-1.1.2.tar.gz | 22.1 kB | Without provenance | Details for argparsethis-1.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| argparsethis-1.1.2-py3-none-any.whl | Python 3 | none | any | Details for argparsethis-1.1.2-py3-none-any.whl |
Total release size: 45.5 kB
Release files / argparsethis-1.1.2.tar.gz
| Download URL | argparsethis-1.1.2.tar.gz |
|---|---|
| Size | 22.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
458893cb9c84968dc6985deb76f03b0ec32cfb489f26c740936b9ebca624d1a6
|
|
BLAKE2b-256 checksum How to use checksums |
3ea35ab4552c0ea48234360480c948cdac08c6272f009f196b4e957b88ecf4e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Release files / argparsethis-1.1.2-py3-none-any.whl
| Download URL | argparsethis-1.1.2-py3-none-any.whl |
|---|---|
| Size | 23.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41581e28501a3d6b5e5c0f449fdd5575e879d6a20f4f2d557d6636a6194e2a90
|
|
BLAKE2b-256 checksum How to use checksums |
f32616e301f9d93f7879ee198165f31dc2ab4e5a6f26b8b831fe1726ba0d68e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9
|
Security for argparsethis 1.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.