os-netloc-rule
A library for matching netloc.
Netloc is a concept to describe the location of a URL, it can be treated as 3-tuple (host, port, scheme)
Netloc match is a very common and useful operation on processing URL. For example, netloc blacklist is a series rules of netloc with ALLOWED or DISALLOWED:
abc.example.com|80|http ALLOWED
.example.com|| DISALLOWED
You can skip processing http://www.example.com/001.html becase it match .example.com|| DISALLOWED.
Install
pip install os-netloc-rule
APIs
-
load netloc and rule
from os_netloc_rule import Matcher netloc_rules = [ ('www.example.com||', 1), ('abc.example.com||', 2), ('abc.example.com|8080|', 3), ] matcher = Matcher() for netloc_string, rule in rules: matcher.load_from_string(netloc_string, rule) -
match netloc
matcher.match('www.example.com') matcher.match('abc.example.com', '8080', 'http') -
if there are same netloc with different rule, the latter covers the former by default. But you can custom your own
cmpfunction when loading rulesdef cmp(former, latter): return -1 if former > latter else 1 matcher.load(host, port, scheme, rule, cmp=cmp) -
iter netloc
for netloc, rule in matcher.iter(): pass
Unit Tests
tox
License
MIT licensed.
Metadata
Release files for os-netloc-rule 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| os-netloc-rule-0.3.tar.gz | 5.9 kB | Without provenance | Details |
Release files / os-netloc-rule-0.3.tar.gz
| Download URL | os-netloc-rule-0.3.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a076f12f5d1a2f63e0c55d86c45358e5d3e23d6f62e58a03e35636b9bbfd88f9
|
|
BLAKE2b-256 checksum How to use checksums |
2297a160cd64aeaf0882e37c0f0190eacd794ed4ac817234b5541e9a92a6c663
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/2.7.15
|
Security for os-netloc-rule 0.3
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.