URN parsing and project-name mapping utilities.
| Function | get |
Extract the trailing identifier from a URN. |
| Function | get |
Extract the project name from a URN. |
| Function | get |
Extract the type segment from a URN. |
| Function | is |
Check whether urn is in a DataGraphs platform namespace. |
| Function | is |
Check whether urn matches the RFC 2141 URN syntax. |
| Function | map |
Recursively replace a URN prefix in all string values of obj. |
| Function | rewrite |
Recursively rewrite URNs in obj to match the target project. |
| Constant | _PLATFORM |
Undocumented |
| Constant | _URN |
Undocumented |
Extract the trailing identifier from a URN.
Returns the segment after the last colon.
| Parameters | |
urn:str | A valid URN string. |
| Returns | |
str | The identifier. |
| Raises | |
ValueError | If urn is not a valid URN. |
Extract the project name from a URN.
Returns the segment between the first and second colons.
| Parameters | |
urn:str | A valid URN string. |
| Returns | |
str | The project name. |
| Raises | |
ValueError | If urn is not a valid URN. |
Extract the type segment from a URN.
Returns the segment between the second and last colons.
| Parameters | |
urn:str | A valid URN string. |
| Returns | |
str | The type segment. |
| Raises | |
ValueError | If urn is not a valid URN. |
Check whether urn is in a DataGraphs platform namespace.
Only the namespace is inspected (case-insensitively, as RFC 2141
requires): use is_valid_urn to check the URN as a whole.
| Parameters | |
urn:str | The string to test. |
| Returns | |
bool | True if urn starts urn:datagraphs: or urn:models:. |
Check whether urn matches the RFC 2141 URN syntax.
| Parameters | |
urn:str | The string to test. |
| Returns | |
bool | True if urn is a valid URN. |
dict | list | str | Any, from_urn: str, to_urn: str) -> dict | list | str | Any:
¶
Recursively replace a URN prefix in all string values of obj.
| Parameters | |
obj:dict | list | str | Any | The object to process (dict, list, str, or other). |
fromstr | URN prefix to replace. |
tostr | Replacement URN prefix. |
| Returns | |
dict | list | str | Any | A copy of obj with URN prefixes replaced. |
dict | list | str | Any, project_name: str) -> dict | list | str | Any:
¶
Recursively rewrite URNs in obj to match the target project.
Every valid URN string has its project segment (between the first and
second colons) replaced with project_name, so urn:my-test:path1:id1
becomes urn:<project_name>:path1:id1. Platform URNs (see
is_platform_urn) and non-URN strings are left as-is.
| Parameters | |
obj:dict | list | str | Any | The object to process (dict, list, str, or other). |
projectstr | The project name to write into each URN. |
| Returns | |
dict | list | str | Any | A copy of obj with URNs rewritten to the target project. |
Undocumented
| Value |
|