Skip to main content

LXML Extension Library for IP address

This library contains LXML extension functions that wrap the Python ipaddress library.

With this library in place, you can do XPath expressions to find IP items within our XML data. For example:

from lxml import etree
from lxml_xpath_ipaddress import ip_ns

# given "config" is an LXML XML structure, you can run the XPath to find all IPv4 network items:

config = etree.parse('tests/config.xml')


items = config.xpath('//*[ip:ip4-net(.)', namespaces=ip_ns)

print(items[0].text)
# >>> 10.10.0.0/16

# Find all items that are in either the 172.18/16 or 101.10.201/24 subnets

items = config.xpath('//*[ip:in-subnet(., "172.18.0.0/16") or ip:in-subnet(., "10.10.201.0/24")]',
                     namespaces=ip_ns)

print(items[0].text)
# >>> 172.18.1.1

Install

$ pip install lxml-xpath-ipaddress

LXML Extension Functions

Either IPv4 or IPv6

  • ip-any(value)
  • ip-net(value)
  • ip-host(value)

IPv4

  • ip4-any(value)
  • ip4-net(value)
  • ip4-host(value)

IPv6

  • ip6-any(value)
  • ip6-net(value)
  • ip6-host(value)

Subnet Checking

  • in-subnet(value, subnet-string)

Python Functions

The library contains these functions as general purpose functions as well, so that they can be used in other applications. See the module doc-strings for use.

Metadata

Release files for lxml-xpath-ipaddress 0.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 lxml-xpath-ipaddress 0.2.0
File Size Uploaded Provenance
lxml-xpath-ipaddress-0.2.0.tar.gz 3.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lxml-xpath-ipaddress 0.2.0
File Interpreter ABI Platform
lxml_xpath_ipaddress-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / lxml-xpath-ipaddress-0.2.0.tar.gz

Download URL lxml-xpath-ipaddress-0.2.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0db34d6d4277c243cf9cf750434b7d30f3c3dfff53b82f4f2f849b9d00a77be8
BLAKE2b-256 checksum
How to use checksums
d53895de062ae456792bd8ece586b1d648f305167a0705320ed53cae631522d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Release files / lxml_xpath_ipaddress-0.2.0-py3-none-any.whl

Download URL lxml_xpath_ipaddress-0.2.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
181445ce60bf6f9eb8bc1594d287577122af60bc31f7c7c59d7bc3240347ea21
BLAKE2b-256 checksum
How to use checksums
3430ab0c1dc10730c4bb6dadfbd7a52309d932f73195e7259c0c4656d91700d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Security for lxml-xpath-ipaddress 0.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

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