Classes:
-
AttrLoaderProtocol–Protocol for functions that load model attributes.
-
ModelBase–Base object for RDF graph models, enforcing all models to have an URI as ID and types.
-
ModelLoader–Class for dynimcally adding functions to load different model attributes.
Functions:
-
get_node_types–Get all types of a node in an RDF graph.
AttrLoaderProtocol
ModelBase
ModelBase(node_id, graph=None, types=None)
Bases: object
Base object for RDF graph models, enforcing all models to have an URI as ID and types.
Attributes:
Parameters:
-
node_id(URIRef) –URI of the model node in the graph
-
graph(Optional[Graph], default:None) –RDF graph for loading types if
typesis not specified -
types(Optional[set[URIRef]], default:None) –the model's types
Methods:
-
get_attr–Get an attribute value.
-
has_attr–Check if the model has an attribute.
-
set_attr–Set an attribute value.
Source code in src/rdf_utils/models/common.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
get_attr
get_attr(key)
Get an attribute value.
Source code in src/rdf_utils/models/common.py
62 63 64 65 66 67 | |
has_attr
has_attr(key)
Check if the model has an attribute.
Source code in src/rdf_utils/models/common.py
54 55 56 | |
set_attr
set_attr(key, val)
Set an attribute value.
Source code in src/rdf_utils/models/common.py
58 59 60 | |
ModelLoader
ModelLoader()
Bases: object
Class for dynimcally adding functions to load different model attributes.
Methods:
-
load_attributes–Load all attributes in the graph into a model with the registered loaders.
-
register–Add a new attribute loader function.
Source code in src/rdf_utils/models/common.py
79 80 | |
load_attributes
load_attributes(graph, model, **kwargs)
Load all attributes in the graph into a model with the registered loaders.
Parameters:
-
graph(Graph) –RDF graph for loading attributes
-
model(ModelBase) –Model object to load attributes into
-
kwargs(Any, default:{}) –any keyword arguments to pass into the loader functions
Source code in src/rdf_utils/models/common.py
90 91 92 93 94 95 96 97 98 99 | |
register
register(loader)
Add a new attribute loader function.
Parameters:
-
loader(AttrLoaderProtocol) –attribute loader function
Source code in src/rdf_utils/models/common.py
82 83 84 85 86 87 88 | |
get_node_types
get_node_types(graph, node_id)
Get all types of a node in an RDF graph.
Parameters:
Returns:
Source code in src/rdf_utils/models/common.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |