pyirk._core.serialization

Serialization-/formatting helpers extracted from :mod:pyirk.core.

The symbols defined here are import-time safe: none of them needs any module-global of core while this module is being imported (their parameter and return annotations use only builtins, stdlib types or directly-imported rdflib.Literal). Symbols that use core module-globals (ds) at call time access them module-qualified via the _core module object, whose attributes are only read once the functions are actually called. This keeps the import monodirectional: core imports this module (early), this module only binds the (partially loaded) core module object.

Note: format_entity_html intentionally stays in :mod:pyirk.core because its parameter annotation references the core class Entity (evaluated at import time, not yet defined when this module is imported). Likewise the module-level LanguageCode instances (df, en, de …) remain in the facade; only the LanguageCode class definition is migrated here.

Module Contents

Classes

LanguageCode

Functions

get_language_of_str_literal

format_literal_html

script_main

export_entities

Data

__all__

API

pyirk._core.serialization.__all__

[‘get_language_of_str_literal’, ‘LanguageCode’, ‘format_literal_html’, ‘script_main’, ‘export_entiti…

pyirk._core.serialization.get_language_of_str_literal(obj: Union[str, rdflib.Literal])
class pyirk._core.serialization.LanguageCode(langtag)

Initialization

__rmatmul__(arg: str) rdflib.Literal

This enables syntax like "test string" @ en (where en is a LanguageCode instance)

:param arg: the string for which the language ist to be specified

:return: Literal instance with .lang attribute set

pyirk._core.serialization.format_literal_html(obj)
pyirk._core.serialization.script_main(fpath)
pyirk._core.serialization.export_entities(path: str = None, to_file=True, uris=True)