Mozilla Repository URLs
Mozilla Repo URLs is a Python library designed to process and centralize the parsing of Mozilla's repository URLs. It provides utilities to break down complex repository URLs into their constituent parts, aiding in automation and consistent handling across various Mozilla projects. The current version is 0.2.2, and it typically sees releases tied to internal Mozilla development needs rather than a fixed public cadence.
Warnings
- gotcha The `parse` function is specifically designed for URLs following Mozilla's repository patterns. Inputting non-Mozilla or malformed URLs may result in unexpected or incomplete parsing results, potentially returning `None` for certain keys or raising exceptions for severely invalid formats.
- gotcha The structure of the returned dictionary from `parse` depends on the type of Mozilla repository URL. Different URL formats (e.g., `hg.mozilla.org/mozilla-central`, `hg.mozilla.org/try`) may yield different sets of keys (e.g., 'revision' might be present for a specific commit URL but not for a base repository URL).
Install
-
pip install mozilla-repo-urls
Imports
- parse
from mozilla_repo_urls import parse
Quickstart
from mozilla_repo_urls import parse
# Example Mozilla repository URL
repo_url = "https://hg.mozilla.org/mozilla-central/file/tip/README.md"
parsed_data = parse(repo_url)
print("Original URL:", repo_url)
for key, value in parsed_data.items():
print(f"{key}: {value}")
# Another example
repo_url_2 = "https://hg.mozilla.org/try/rev/abcdef123456"
parsed_data_2 = parse(repo_url_2)
print("\nOriginal URL 2:", repo_url_2)
for key, value in parsed_data_2.items():
print(f"{key}: {value}")