artifact_urls¶
src.utils.normalization.artifact_urls
¶
Shared helpers for classifying artifact URLs by hosting source.
Provides
resolve_doi_prefix(url) — Map a DOI to its repository name (Zenodo, Figshare, …). extract_source(url) — Determine the hosting source of an artifact URL. get_artifact_url(artifact, normalise_fn) — Extract the first valid URL from an artifact dict. get_artifact_urls(artifact, normalise_fn) — Extract all valid URLs from an artifact dict.
resolve_doi_prefix(url: str) -> str | None
¶
Map a DOI URL to the name of its repository (e.g. 'Zenodo').
Returns None if the DOI prefix is unrecognised or the URL contains no DOI.
Source code in src/utils/normalization/artifact_urls.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
extract_source(url: str) -> str
¶
Classify an artifact URL by its hosting platform.
Returns a human-readable label such as 'GitHub', 'Zenodo',
'Figshare', 'OSF', 'GitLab', 'Bitbucket', 'DOI',
'Other', or 'unknown' when url is empty/None.
Source code in src/utils/normalization/artifact_urls.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
get_artifact_url(artifact: dict, normalise_fn: object = None) -> str | None
¶
Return the first valid URL from artifact, or None.
Parameters¶
artifact : dict
An artifact record (as produced by parse_results_md).
normalise_fn : callable, optional
A function str -> str|None that normalises raw URL values.
Defaults to identity (returns the value as-is).
Source code in src/utils/normalization/artifact_urls.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
get_artifact_urls(artifact: dict, normalise_fn=None) -> list[str]
¶
Return all valid URLs from artifact.
Parameters¶
artifact : dict
An artifact record.
normalise_fn : callable, optional
A function str -> str|None that normalises raw URL values.
Source code in src/utils/normalization/artifact_urls.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |