About
Additional PYthon argparse types and actions.
Project homepage: https://github.com/eerimoq/argparse_addons
Installation
$ pip install argparse_addons
Examples
Integer range type
The script. See examples/integer_range_type.py for the complete script.
parser.add_argument('--min-max',
type=argparse_addons.IntegerRangeType(0, 255))
parser.add_argument('--min',
type=argparse_addons.IntegerRangeType(0, None))
parser.add_argument('--max',
type=argparse_addons.IntegerRangeType(None, 255))
Error message for the range 0..255.
$ python3 examples/integer_range_type.py --min-max -1
usage: integer_range_type.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX]
integer_range_type.py: error: argument --min-max: -1 is not in the range 0..255
Error message for the range 0..inf.
$ python3 examples/integer_range_type.py --min -1
usage: integer_range_type.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX]
integer_range_type.py: error: argument --min: -1 is not in the range 0..inf
Error message for the range -inf..255.
$ python3 examples/integer_range_type.py --max 1000
usage: integer_range_type.py [-h] [--min-max MIN_MAX] [--min MIN] [--max MAX]
integer_range_type.py: error: argument --max: 1000 is not in the range -inf..255
All values within allowed ranges.
$ python3 examples/integer_range_type.py --min-max 47 --min 1000 --max -5
--min-max: 47
--min: 1000
--max: -5
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.3.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.3.0.tar.gz | 3.6 kB | Details |
Release files / argparse_addons-0.3.0.tar.gz
| Download URL | argparse_addons-0.3.0.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f6f46231d889a79f5cc82f9ba09c38d32db3b604b1fc6747d37c14f6678b5d40
|
|
BLAKE2b-256 checksum How to use checksums |
66fbc86f135078f80ffedc25dfca6100e7f9664b5f55a04466f6cbe5b95bbfa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.0
|