Skip to main content

Port Range

Like Python’s standard library ipaddress package, but for ports.

Stable release: Last release Python versions Software license Requirements freshness

Development: Unit-tests status Coverage Status Code Quality

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.

Metadata

Release files for port-range 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for port-range 2.2.0
File Size Uploaded Provenance Actions
port-range-2.2.0.tar.gz 9.6 kB Without provenance Details for port-range-2.2.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for port-range 2.2.0
File Interpreter ABI Platform Actions
port_range-2.2.0-py3.7.egg Legacy Egg format - - Details for port_range-2.2.0-py3.7.egg
port_range-2.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for port_range-2.2.0-py2.py3-none-any.whl

Total release size: 32.1 kB

Release files / port-range-2.2.0.tar.gz

Download URL port-range-2.2.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9f82644e3a2597ad24dcb8bb29688d7af042b4b83f8f476640eb726f30d6ef21
BLAKE2b-256 checksum
How to use checksums
ea3b7ffc718e1555b98d7ba2b22e63435f40f041050d60918b16107d3cb2e377
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / port_range-2.2.0-py3.7.egg

Download URL port_range-2.2.0-py3.7.egg
Size 13.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
07731cfd49f366bd2b39ec84db60daf6fc2da0b30a9bc5fc4d7737dc8c3f6f38
BLAKE2b-256 checksum
How to use checksums
9d5657f20245c1a2d37d8d126c01b422abd8243a57de88978328cd4733c17340
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Release files / port_range-2.2.0-py2.py3-none-any.whl

Download URL port_range-2.2.0-py2.py3-none-any.whl
Size 8.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
872f97b8086e3eb790cc2a3162b429d58d51d5e96f180d42ac0188def1964086
BLAKE2b-256 checksum
How to use checksums
4591455c904ed8cf8d8118dc113bb9e88beedbbde7967fd9f9587b0af6f2aab8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

Security for port-range 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page