module documentation

URN parsing, project-name mapping, and schema transformation utilities.

Class SchemaTransformer Transforms schemas between legacy (old) and new format.
Function get_id_from_urn Extract the trailing identifier from a URN.
Function get_project_from_urn Extract the project name from a URN.
Function get_type_from_urn Extract the type segment from a URN.
Function is_valid_urn Check whether urn matches the RFC 2141 URN syntax.
Function map_project_name Recursively replace a URN prefix in all string values of obj.
Constant _URN_PATTERN Undocumented
def get_id_from_urn(urn: str) -> str:

Extract the trailing identifier from a URN.

Returns the segment after the last colon.

Parameters
urn:strA valid URN string.
Returns
strThe identifier.
Raises
ValueErrorIf urn is not a valid URN.
def get_project_from_urn(urn: str) -> str:

Extract the project name from a URN.

Returns the segment between the first and second colons.

Parameters
urn:strA valid URN string.
Returns
strThe project name.
Raises
ValueErrorIf urn is not a valid URN.
def get_type_from_urn(urn: str) -> str:

Extract the type segment from a URN.

Returns the segment between the second and last colons.

Parameters
urn:strA valid URN string.
Returns
strThe type segment.
Raises
ValueErrorIf urn is not a valid URN.
def is_valid_urn(urn: str) -> bool:

Check whether urn matches the RFC 2141 URN syntax.

Parameters
urn:strThe string to test.
Returns
boolTrue if urn is a valid URN.
def map_project_name(obj: 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 | AnyThe object to process (dict, list, str, or other).
from_urn:strURN prefix to replace.
to_urn:strReplacement URN prefix.
Returns
dict | list | str | AnyA copy of obj with URN prefixes replaced.
_URN_PATTERN =

Undocumented

Value
re.compile(r'^[Uu][Rr][Nn]:(?![Uu][Rr][Nn]-)[a-zA-Z0-9][a-zA-Z0-9-]{1,31}:(?:[a-
zA-Z0-9\(\)\+,-\.:=@;\$_!\*\']|%[0-9A-Fa-f]{2})+$')