About
Additional Python argparse types and actions.
Project homepage: https://github.com/eerimoq/argparse_addons
Installation
$ pip install argparse_addons
Examples
Integer type
The script. See examples/integer.py for the complete script.
parser.add_argument('--min-max',
type=argparse_addons.Integer(0, 255))
parser.add_argument('--min',
type=argparse_addons.Integer(0, None))
parser.add_argument('--max',
type=argparse_addons.Integer(None, 255))
parser.add_argument('--any',
type=argparse_addons.Integer())
Error message for the --min-max argument.
$ python3 examples/integer.py --min-max -1
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --min-max: -1 is not in the range 0..255
Error message for the --min argument.
$ python3 examples/integer.py --min -1
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --min: -1 is not in the range 0..inf
Error message for the --max argument.
$ python3 examples/integer.py --max 1000
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --max: 1000 is not in the range -inf..255
Error message for the --any argument.
$ python3 examples/integer.py --any a
usage: integer.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX] [--any ANY]
integer.py: error: argument --any: invalid integer value: 'a'
All values within allowed ranges.
$ python3 examples/integer.py --min-max 47 --min 1000 --max -5 --any 1
--min-max: 47
--min: 1000
--max: -5
--any: 1
Contributing
Fork the repository.
Install prerequisites.
pip install -r requirements.txtImplement the new feature or bug fix.
Implement test case(s) to ensure that future changes do not break legacy.
Run the tests.
make testCreate a pull request.
Metadata
Release files for argparse-addons 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| argparse_addons-0.9.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argparse_addons-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.0 kB
Release files / argparse_addons-0.9.0.tar.gz
| Download URL | argparse_addons-0.9.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d101a7196c002b371fa3498aae273ced4f49b43f8d7a9c3ba2c1b1d55528967f
|
|
BLAKE2b-256 checksum How to use checksums |
80183c60d211e6ea0438a63852df438bac15c8c203dfa5995ebd22f5e1ce77d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / argparse_addons-0.9.0-py3-none-any.whl
| Download URL | argparse_addons-0.9.0-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
314dedc5d8ea55d91566dd5f7fb93aad1bc674661d44aec100278fbfaa576682
|
|
BLAKE2b-256 checksum How to use checksums |
245d73286a08f1c3f25af0936d1f1ba0dccaf3babc1e6f3f99fb7b8efa2e5a86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|