Net¶
net
¶
Functions:
| Name | Description |
|---|---|
clean_url |
Strip credentials from a URL and normalise the scheme to https. |
encode_url |
Re-encode a GitHub repository URL in a given scheme. |
get_public_repo_url |
Return the public HTTPS URL of a GitHub repository. |
make_json_get |
Perform an HTTP GET request and return the parsed JSON response. |
parse_repository_url |
Parse a GitHub repository URL and return its canonical form with owner and repo. |
sparse_clone |
Clone a remote repository with sparse checkout limited to specific paths. |
clean_url
¶
Strip credentials from a URL and normalise the scheme to https.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Raw URL string, possibly containing user:password@ credentials. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cleaned URL using https with credentials removed. |
Source code in oops/utils/net.py
encode_url
¶
Re-encode a GitHub repository URL in a given scheme.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Source repository URL in any supported format. |
required |
|
str
|
Target scheme, either "https" or "ssh". |
required |
|
bool
|
If True, append ".git" to HTTPS URLs. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Re-encoded URL string in the requested scheme. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the scheme is not "https" or "ssh". |
Source code in oops/utils/net.py
get_public_repo_url
¶
make_json_get
¶
Perform an HTTP GET request and return the parsed JSON response.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
URL to request. |
required |
|
Optional[dict]
|
Optional HTTP headers to include. |
None
|
|
Optional[dict]
|
Optional query parameters to include. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Parsed JSON response as a dict. |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If the response status indicates an error. |
Source code in oops/utils/net.py
parse_repository_url
¶
Parse a GitHub repository URL and return its canonical form with owner and repo.
Supported formats: HTTPS (with or without .git, with or without branch path),
SSH (git@github.com:owner/repo.git), and ssh:// URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
GitHub repository URL to parse. |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str, str, str]
|
Tuple of (canonical_https_url, owner, repo). Owner is upper-cased for OCA. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the URL cannot be parsed or the host is not github.com. |
Source code in oops/utils/net.py
sparse_clone
¶
Clone a remote repository with sparse checkout limited to specific paths.
Performs a shallow clone (depth=1) and enables sparse checkout so only the listed files or directories are materialised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
URL of the remote repository to clone. |
required |
|
Path
|
Local directory where the repository will be cloned. |
required |
|
list
|
List of file or directory patterns to include in the sparse checkout. |
required |
|
Optional[str]
|
Branch to clone. If None, clones the remote default branch. |
None
|