Port range with support of CIDR-like notation.
Project description
Port range with support of CIDR-like notation.
Features
Support CIDR-like notation:
>>> from port_range import PortRange
>>> pr = PortRange('1027/15')
>>> pr.port_from
1027
>>> pr.port_to
1028
>>> pr.bounds
(1027, 1028)
Parse and normalize port ranges:
>>> pr = PortRange(' 4242-42 ')
>>> pr.bounds
(42, 4242)
>>> str(pr)
'42-4242'
Enforce strong validatation in strict mode:
>>> PortRange(' 4242-42 ', strict=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "port_range/__init__.py", line 62, in __init__
self.port_from, self.port_to = self.parse(port_range)
File "port_range/__init__.py", line 109, in parse
raise ValueError("Invalid reversed port range.")
ValueError: Invalid reversed port range.
Access to decimal-representation properties:
>>> pr = PortRange('1027/15')
>>> pr.base
1027
>>> pr.prefix
15
>>> pr.mask
1
>>> pr.offset
3
License
This software is licensed under the BSD 2-Clause License.
Changes for v2.0.0 (2015-12-19)
Refactor parsing. Makes normal mode stricter and strict mode more rigorous.
Expose is_single_port and is_cidr properties in repr().
Unittests covers 100% of code.
Add default isort config.
Run unittests against Python 3.3, 3.5, 3.6-dev, 3.7-dev, PyPy2.7 and PyPy3.3.
Remove popularity badge: PyPI download counters are broken and no longer displayed.
Move coverage config to setup.cfg.
Add test and develop dependencies.
Only show latest changes in the long description of the package instead of the full changelog.
Replace pep8 package by pycodestyle.
Enforce pycodestyle checks in Travis CI jobs.
Test production of packages in Travis CI jobs.
Always check for package metadata in Travis CI jobs.
Make wheels generated under Python 2 environnment available for Python 3 too.
Add link to full changelog in package’s long description.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file port-range-2.0.0.tar.gz
.
File metadata
- Download URL: port-range-2.0.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d003f20e06c0df15cf4f47983f327cad4522c6a8b9cf4aadb42f05aef5a0614f |
|
MD5 | e7894b713e3ce52928f1e4be6792c7ef |
|
BLAKE2b-256 | 70452282b2ed1b75c80205d080ebaf93d717ce0e793c08ceddb69a36a884f07e |
File details
Details for the file port_range-2.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: port_range-2.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9ef86a954c5a6ad0668181d0ff414e1caa94f11a767ea3dec1a4f57b9a2755a |
|
MD5 | 84cc0395ce9694caa6633d04ea581eb1 |
|
BLAKE2b-256 | fcc77b2310ef1cea5e12a0e90d0dedd1886c4c83ee52d621a0747b9e0ac5dcbb |
File details
Details for the file port_range-2.0.0-py2.7.egg
.
File metadata
- Download URL: port_range-2.0.0-py2.7.egg
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07b9ffd102c894391af6036699f2d9abc84234867fc3ad56e8eb394b7f738e26 |
|
MD5 | fee3ee9e685c72da857bdb9a837a939b |
|
BLAKE2b-256 | d4852b1cddbd8c5c7cfab2c81c39666382431d5ac3e0251fe56a55d2de6cc87a |