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.
pip install mozilla-repo-urlsVerified import paths — ran on the pinned version, not inferred.
The primary function `parse` takes a Mozilla repository URL string and returns a dictionary containing its parsed components, such as 'base', 'repo', 'path', 'revision', and 'type'.
Always validate input URLs to ensure they conform to expected Mozilla repository URL structures before passing them to `parse`. Consult Mozilla's internal documentation for precise URL patterns if encountering issues.
Implement robust error handling and check for the presence of expected keys in the returned dictionary before accessing their values. Consider providing default values or branching logic based on the 'type' key if multiple URL patterns are processed.
```python from mozilla_repo_urls import parse # or import mozilla_repo_urls ```
```python
from mozilla_repo_urls import parse
repo_url = "not-a-mozilla-url"
parsed_data = parse(repo_url)
if parsed_data is None:
print(f"Error: Could not parse URL: {repo_url}. It may be malformed or not a recognized Mozilla repository URL.")
else:
# Proceed with using parsed_data
print(parsed_data.get('repo'))
``````python
from mozilla_repo_urls import parse
repo_url = "https://hg.mozilla.org/mozilla-central"
parsed_data = parse(repo_url)
# Safely access keys using .get() with a default value
revision = parsed_data.get('revision', 'N/A')
print(f"Repo: {parsed_data.get('repo')}, Revision: {revision}")
# Or check for key existence before direct access
if 'revision' in parsed_data:
print(f"Revision: {parsed_data['revision']}")
else:
print("No revision found for this URL type.")
```No dependency data recorded yet.