urn:<id_source>[:<id_type>]:<id_key>
comicbox.identifiers.urns¶
source module comicbox.identifiers.urns
Universal Resource Name support.
Comicbox writes and reads one shape of RFC 8141 urn
The type segment is written only when the identifier’s type differs from the one implied by where it sits, which for a urn is always issue. Both forms parse, as do the typed urns comicbox wrote before v3 and comicvine long codes.
These functions never raise. A source or key that cannot form a legal urn yields the empty string rather than an exception, because the notes stamp composes urns from arbitrary user-supplied identifier sources.
Functions
-
parse_urn_identifier — Parse an identifier from a urn.
-
parse_string_identifier — Parse identifiers from strings or xml dicts.
-
to_urn_string — Compose an urn string.
source parse_urn_identifier(tag: str) → tuple[IdSources | None, str, str]
Parse an identifier from a urn.
source parse_string_identifier(item: str, default_id_source: IdSources | None = None) → tuple[IdSources | None, str, str]
Parse identifiers from strings or xml dicts.
source to_urn_string(id_source_str: str, id_type: str, id_key_str: str) → str
Compose an urn string.
Returns the empty string for parts that cannot make a legal urn, so a hand written identifier source or key never aborts a read. A key is checked against the same grammar the notes scanner looks for, because a urn comicbox writes but cannot find again is worse than no urn: the scanner would stop at the first illegal character and record the truncated head as the id.