Skip to main content

URL matching rules library to connect URLs with resources

Project description

PyPI Version Supported Python Versions Build Status Coverage report

URL matching library that relates URLs with resources. Rules are defined using simple pattern definitions. It is simpler and faster than using regular expressions if the rules involves many domains.

To illustrate it with an example, imagine that you have several proxy servers and you want to route requests to the right one. You could define the following rules:

  • site1.com →︎ us_proxy

  • site2.com/uk →︎ uk_proxy

  • site2.com/ie →︎ ie_proxy

All URLs from site1.com should use the US proxy. The situation for site2.com URLs are different: if the path starts with /uk, then use the UK proxy, otherwise use the IE proxy. This library allows to create a matcher that can be used to match URLs with the right proxy using these rules.

Have a look to https://github.com/zytedata/url-matcher/blob/main/url_matcher/example.py for an example of usage.

The following files are useful to understand the pattern, the set of patterns and how they behave:

The full documentation can be found at https://url-matcher.readthedocs.io/

License is BSD 3-clause.

Developing

Setup your local Python environment via:

  1. pip install -r requirements-dev.txt

  2. pre-commit install

Now everytime you perform a git commit, these tools will run against the staged files:

  • black

  • isort

  • flake8

  • mypy

You can also directly invoke pre-commit run --all-files to run them without performing a commit.

Using sphinx-autobuild

When working on documentation, it is convenient to use sphinx-autobuild. First, run pip install -r docs/requirements.txt sphinx-autobuild. Then run

sphinx-autobuild docs docs/_build/html

and then open http://127.0.0.1:8000/ in a browser, to see the current version of docs. A process would be running in a background, watching for docs changes; when docs are changed, a build is started, and the web page is refreshed automatically when the build is finished.

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

url-matcher-0.2.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

url_matcher-0.2.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file url-matcher-0.2.0.tar.gz.

File metadata

  • Download URL: url-matcher-0.2.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for url-matcher-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b90d6c2edd2b1d07037e8e9b9e3f6139f02c14825346695bc3898b0264e6a15c
MD5 789861799d13d1d76c92ccd6cab5f621
BLAKE2b-256 b0cd300a9becfbc537352b13afd590a190530516975beea3e0ca9cedf4acefca

See more details on using hashes here.

File details

Details for the file url_matcher-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: url_matcher-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2

File hashes

Hashes for url_matcher-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 73bc20dd3758762052b23aa5702bf10c94c6f0e4cb140d60187f407956bc34c9
MD5 e429e305b7ef8caa9850d05abfe4f099
BLAKE2b-256 35cd759090789cac9c9d18aa6111e741d1634cc3cadb6ca667616a8a51036562

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page