util
General utilities module.
copy_triples(src, dst=None)
Copies all triples from one graph onto another (or a new, empty Graph if none is provided).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src
|
Graph
|
the source Graph |
required |
dst
|
Optional[Graph]
|
the destination Graph (or |
None
|
Returns:
Type | Description |
---|---|
Graph
|
the destination Graph |
Source code in ogc/na/util.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
dump_yaml(content, filename=None, ignore_alises=True, **kwargs)
Generates YAML output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
Any
|
content to convert to YAML. |
required |
filename
|
str | Path | None
|
optional filename to dump the content into. If None, string content will be returned. |
None
|
kwargs
|
other args to pass to |
{}
|
Source code in ogc/na/util.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
entail(g, rules, extra=None, inplace=True)
Performs SHACL entailments on a data Graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g
|
Graph
|
input data Graph |
required |
rules
|
Graph
|
SHACL Graph for entailments |
required |
extra
|
Optional[Graph]
|
Graph with additional ontological information for entailment |
None
|
inplace
|
bool
|
if |
True
|
Returns:
Type | Description |
---|---|
Graph
|
the resulting Graph |
Source code in ogc/na/util.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
is_url(url, http_only=False)
Checks whether a string is a valid URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
url
|
str
|
the input string |
required |
http_only
|
bool
|
whether to only accept HTTP and HTTPS URLs as valid |
False
|
Returns:
Type | Description |
---|---|
bool
|
|
Source code in ogc/na/util.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
load_yaml(filename=None, content=None, url=None, safe=True)
Loads a YAML file either from a file, a string or a URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename
|
str | Path | None
|
YAML document file name |
None
|
content
|
Any | None
|
str with YAML contents |
None
|
url
|
str | None
|
url from which to retrieve the contents |
None
|
safe
|
bool
|
whether to use safe YAMl loading |
True
|
Returns:
Type | Description |
---|---|
dict
|
a dict with the loaded data |
Source code in ogc/na/util.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
merge_contexts(a, b, fix_nest=True)
Merges two JSON-lD contexts, updating the first one passed to this function (and returning it).
Source code in ogc/na/util.py
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
parse_resources(src)
Join one or more RDF documents or Graph's together into a new Graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src
|
Union[str, Graph, list[Union[str, Graph]]]
|
a path or Graph, or list thereof |
required |
Returns:
Type | Description |
---|---|
Graph
|
a union Graph |
Source code in ogc/na/util.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
validate(g, shacl_graph, extra=None, **kwargs)
Perform SHACL validation on a data Graph.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
g
|
Graph
|
input data Graph |
required |
shacl_graph
|
Graph
|
SHACL graph for validation |
required |
extra
|
Optional[Graph]
|
Graph with additional ontological information for validation |
None
|
Returns:
Type | Description |
---|---|
ValidationReport
|
Source code in ogc/na/util.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|