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 validation 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.1.0 (2017-08-02)
Rename port_lenght property to port_length.
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
port-range-2.1.0.tar.gz
(9.4 kB
view details)
Built Distributions
port_range-2.1.0-py2.7.egg
(7.3 kB
view details)
File details
Details for the file port-range-2.1.0.tar.gz
.
File metadata
- Download URL: port-range-2.1.0.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30c1b17902cd3a748c1bac2e4a7b8997990e5a26f372cf76f6d940530de78b29 |
|
MD5 | ae86e6cd71af132e74856004fb011a8d |
|
BLAKE2b-256 | 5a9e5db7bed7ceba896050f7ee353aa1c68a42f23c130d7b762eeccb62829e3d |
File details
Details for the file port_range-2.1.0-py2.py3-none-any.whl
.
File metadata
- Download URL: port_range-2.1.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0423344c79a97b3ff3eee14155bfdb8741830911e2890161960716989b88cdf4 |
|
MD5 | d4970b55004e413b609e19fb18587bdb |
|
BLAKE2b-256 | cd9d10249726c6d8a2c33b6262c92444549355e78aac61c29d3d3b50d71919b7 |
File details
Details for the file port_range-2.1.0-py2.7.egg
.
File metadata
- Download URL: port_range-2.1.0-py2.7.egg
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f722ec83fbc39e23bb7c2d192acce26a48574111b6e417672a8a1df9e57d5a82 |
|
MD5 | 727d319662dfa2a7e51991f55c5b048e |
|
BLAKE2b-256 | 46088e3f8dd429e266cfd79f808b7b3ff3334de17ecdcd0e8dd6c738ee079864 |