ld
Helpers to create pydantic models that parse into and (de-)serialize to JSON-LD.
ld
module-attribute
¶
ld = ld_decorator()
Decorator to add constant JSON-LD fields equal for all instances of a schema.
LDOrRef
module-attribute
¶
LDOrRef: TypeAlias = Union[LDIdRef, T]
LDOrRef[T] is either an object of LD Schema T, or a reference to an object.
An LD reference is just an object with an @id.
LDRef
module-attribute
¶
LDRef: TypeAlias = LDIdRef
LDRef[T] is a reference to an object of type T.
An LD reference is just an object with an @id.
LDSchema ¶
Bases: MetadataSchema
Semantically enriched schema for JSON-LD.
Source code in src/metador_core/schema/ld.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
ref ¶
ref() -> LDIdRef
Return LDIdRef, i.e. a pure @id reference for object.
Throws an exception if no @id is found.
Source code in src/metador_core/schema/ld.py
57 58 59 60 61 62 63 64 |
|
LDIdRef ¶
Bases: LDSchema
Object with just an @id reference (more info is given elsewhere).
Source code in src/metador_core/schema/ld.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
with_key_prefix ¶
with_key_prefix(
prefix: str, dct: Mapping[str, Any]
) -> Dict[str, Any]
Return new dict with all keys prefixed by prefix
.
Source code in src/metador_core/schema/ld.py
15 16 17 |
|
ld_decorator ¶
ld_decorator(**presets)
Return LD schema decorator with pre-set fields, e.g. @context
.
The returned decorator will attach the passed fields to a schema.
All additional fields passed to the decorator will also be added, if not present, or override the default that is passed to this function.
Note that the pre-set fields will ALWAYS override existing fields, regardless of the state of the override flag.
Example usage:
Pass your @context
as context
to this decorator factory.
Use the returned decorator with type
in order to
set both the @context
and @type
for a schema.
By default, will silently override any inherited constant fields that already exist in the schema.
Source code in src/metador_core/schema/ld.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|