Registry / devops / mozilla-repo-urls

mozilla-repo-urls

JSON →
library0.2.2pypypi✓ verified 22d ago

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-urls
INSTALL
IMPORT
SIG · MOZILLA-REPO-URLS
M
mozilla-repo-urls
devopspythonv0.2.2
Install
1.6s avg
Import
27ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.028s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.026s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
from mozilla_repo_urls import parse

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'.

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}")
Debug
Known issues
gotchaThe `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.
fix
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.
affects: All versions
gotchaThe 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).
fix
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.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'mozilla-repo-urls'
The Python package name 'mozilla-repo-urls' uses hyphens, but when importing in Python, hyphens must be replaced with underscores, so the correct module name is 'mozilla_repo_urls'.
fix
```python
from mozilla_repo_urls import parse
# or
import mozilla_repo_urls
```
AttributeError: 'NoneType' object has no attribute 'get'
The `parse` function returned `None` because the input URL was either malformed or did not conform to expected Mozilla repository URL patterns, and the subsequent code attempted to access attributes or keys on this `None` result.
fix
```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'))
```
KeyError: 'revision'
The `parse` function returns a dictionary whose structure varies based on the input URL. This `KeyError` indicates that the 'revision' key (or any other specific key) was expected but was not present in the dictionary returned for the given repository URL type.
fix
```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.")
```
Upgrade
Version history
0.2.2latest on PyPI · released Jun 3, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
mozilla-repo-urls — pip install mozilla-repo-urls · libregistry