arguments
Argument parser based on docopt
install
pip install arguments
usage
Docopt is used for parsing the docstring (doc), arguments bundles the schema parser and returns a OptionParser like object with normalized attributes
For example
arguments test Usage: tests.py <posarg1> <posarg2> Options: -h --help Show this screen. -o --option=<option1> An option. --option2=<option2> An option [default: hello]. -p --parameter=<parameter> Folder to check the git repos out [default: 77]. -v --verbose Folder from where to run the command [default: .].
called like
python tests.py pval1 pval2
will when called in python return
>>> myargs = Arguments()
>>> print myargs.posarg1
pyval1
>>> print myargs.posarg2
pyval2
Using schema
Assume you are using docopt with the following usage-pattern:
my_program.py [--count=N] <path> <files>
and you would like to validate that <files> are readable, and that <path> exists, and that --count is either integer from 0 to 5, or None.
this is how you validate it using schema:
>>> from arguments import *
>>> s = Schema({'<files>': [Use(open)],
... '<path>': os.path.exists,
... '--count': Or(None, And(Use(int), lambda n: 0 < n < 5))})
>>> args = Arguments(validateschema=s)
>>> args.files
[<open file 'LICENSE-MIT', mode 'r' at 0x...>, <open file 'setup.py', mode 'r' at 0x...>]
>>> args.path
'../'
>>> args.count
3
As you can see, it validated data successfully, opened files and converted '3' to int.
Metadata
Release files for arguments 11
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 |
|---|---|---|---|---|
| arguments-11.tar.gz | 6.2 kB | Without provenance | Details for arguments-11.tar.gz |
Release files / arguments-11.tar.gz
| Download URL | arguments-11.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd2efdef55ea7ea723930993d8e672710640c3127d66a5dd2312e175a0802e91
|
|
BLAKE2b-256 checksum How to use checksums |
4f5f800a6ec057eb2ff66ad5b657fae882e9794a72043cebf8434d8bf709da49
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for arguments 11
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.