port-range 2.2.0

Creator: bradpython12

Last updated:

0 purchases

port-range 2.2.0 Image
port-range 2.2.0 Images
Add to Cart

Description:

portrange 2.2.0

Like Python’s standard library ipaddress package, but for ports.
Stable release:
Development:

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.2.0 (2019-09-19)


Fix Travis build
Implement equality and hash operators
Fix deprecated collections warning


Full changelog.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.