Skip to content

Commit 91bae5e

Browse files
authored
Merge pull request #144 from casework/export_local_uuid
Additional parts for exporting `local_uuid`
2 parents afcb069 + 6effb63 commit 91bae5e

File tree

6 files changed

+14
-57
lines changed

6 files changed

+14
-57
lines changed

case_utils/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@
1515
# We would appreciate acknowledgement if the software is used.
1616

1717
__version__ = "0.14.1.post0"
18-
19-
from . import local_uuid # noqa: F401

case_utils/case_file/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
import typing
2929
import warnings
3030

31+
import cdo_local_uuid
3132
import rdflib
33+
from cdo_local_uuid import local_uuid
3234

3335
import case_utils.inherent_uuid
3436
from case_utils.namespace import (
@@ -94,7 +96,7 @@ def create_file_node(
9496
node_namespace = rdflib.Namespace(node_prefix)
9597

9698
if node_iri is None:
97-
node_slug = "File-" + case_utils.local_uuid.local_uuid()
99+
node_slug = "File-" + local_uuid()
98100
node_iri = node_namespace[node_slug]
99101
n_file = rdflib.URIRef(node_iri)
100102
graph.add((n_file, NS_RDF.type, NS_UCO_OBSERVABLE.File))
@@ -110,7 +112,7 @@ def create_file_node(
110112
n_file, NS_UCO_OBSERVABLE.FileFacet, namespace=node_namespace
111113
)
112114
else:
113-
n_file_facet = node_namespace["FileFacet-" + case_utils.local_uuid.local_uuid()]
115+
n_file_facet = node_namespace["FileFacet-" + local_uuid()]
114116

115117
graph.add(
116118
(
@@ -144,9 +146,7 @@ def create_file_node(
144146
n_file, NS_UCO_OBSERVABLE.ContentDataFacet, namespace=node_namespace
145147
)
146148
else:
147-
n_contentdata_facet = node_namespace[
148-
"ContentDataFacet-" + case_utils.local_uuid.local_uuid()
149-
]
149+
n_contentdata_facet = node_namespace["ContentDataFacet-" + local_uuid()]
150150

151151
graph.add((n_file, NS_UCO_CORE.hasFacet, n_contentdata_facet))
152152
graph.add(
@@ -248,7 +248,7 @@ def create_file_node(
248248
)
249249
)
250250
else:
251-
hash_uuid = case_utils.local_uuid.local_uuid()
251+
hash_uuid = local_uuid()
252252
n_hash = node_namespace["Hash-" + hash_uuid]
253253

254254
graph.add((n_contentdata_facet, NS_UCO_OBSERVABLE.hash, n_hash))
@@ -291,7 +291,7 @@ def main() -> None:
291291

292292
logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
293293

294-
case_utils.local_uuid.configure()
294+
cdo_local_uuid.configure()
295295

296296
NS_BASE = rdflib.Namespace(args.base_prefix)
297297

@@ -314,7 +314,7 @@ def main() -> None:
314314
context_dictionary = {k: v for (k, v) in graph.namespace_manager.namespaces()}
315315
serialize_kwargs["context"] = context_dictionary
316316

317-
node_iri = NS_BASE["File-" + case_utils.local_uuid.local_uuid()]
317+
node_iri = NS_BASE["File-" + local_uuid()]
318318
create_file_node(
319319
graph,
320320
args.in_file,

case_utils/inherent_uuid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
2. A pattern based on inherence generates UUIDv5s based on how an inherent object (a.k.a. UcoInherentCharacterizationThing) structurally relates to the object in which it inheres. For instance, a Facet is understood to only relate to its UcoObject by linking with the uco-core:hasFacet property. So, a Facet's UUID is determined uniquely by (1) the "UUID namespace" of its corresponding UcoObject, and (2) its OWL Class.
2424
A. The term "UUID namespace" is described in RFC 4122 Section 4.3 [#rfc4122s43]_ , and is not intended be confused with `rdflib.term.Namespace`. For any uco-core:UcoThing (or even owl:Thing), the function `inherence_uuid` defines the procedure for either extracting or generating a UUID for use as a namespace.
2525
26-
This module is independent of, and complements, `case_utils.local_uuid`, which provides deterministic UUIDs based on calling process's environment.
26+
This module is independent of, and complements, `cdo_local_uuid.local_uuid`, which provides deterministic UUIDs based on calling process's environment.
2727
2828
References
2929
==========

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ license_files =
1919
[options]
2020
include_package_data = true
2121
install_requires =
22-
cdo-local-uuid >= 0.4.0, < 0.5.0
22+
cdo-local-uuid >= 0.5.0, < 0.6.0
2323
pandas
2424
pyshacl >= 0.24.0
2525
rdflib < 8

tests/case_utils/case_file/Makefile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,10 @@ sample.txt.json: \
117117
$(tests_srcdir)/src/isomorphic_diff.py \
118118
$(top_srcdir)/case_utils/case_file/__init__.py \
119119
$(top_srcdir)/case_utils/inherent_uuid.py \
120-
$(top_srcdir)/case_utils/local_uuid.py \
121120
$(top_srcdir)/case_utils/namespace.py \
122121
sample.txt-nocompact.json
123122
rm -f $@ _$@ __$@
124-
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
123+
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
125124
&& source $(tests_srcdir)/venv/bin/activate \
126125
&& case_file \
127126
--debug \
@@ -152,11 +151,10 @@ sample.txt.ttl: \
152151
$(tests_srcdir)/.venv.done.log \
153152
$(top_srcdir)/case_utils/case_file/__init__.py \
154153
$(top_srcdir)/case_utils/inherent_uuid.py \
155-
$(top_srcdir)/case_utils/local_uuid.py \
156154
$(top_srcdir)/case_utils/namespace.py \
157155
sample.txt.done.log
158156
rm -f _$@ __$@
159-
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
157+
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
160158
&& source $(tests_srcdir)/venv/bin/activate \
161159
&& case_file \
162160
--debug \
@@ -178,11 +176,10 @@ sample.txt-disable_hashes.ttl: \
178176
$(tests_srcdir)/.venv.done.log \
179177
$(top_srcdir)/case_utils/case_file/__init__.py \
180178
$(top_srcdir)/case_utils/inherent_uuid.py \
181-
$(top_srcdir)/case_utils/local_uuid.py \
182179
$(top_srcdir)/case_utils/namespace.py \
183180
sample.txt.done.log
184181
rm -f _$@ __$@
185-
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
182+
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
186183
&& source $(tests_srcdir)/venv/bin/activate \
187184
&& case_file \
188185
--debug \
@@ -206,11 +203,10 @@ sample.txt-nocompact.json: \
206203
$(tests_srcdir)/src/isomorphic_diff.py \
207204
$(top_srcdir)/case_utils/case_file/__init__.py \
208205
$(top_srcdir)/case_utils/inherent_uuid.py \
209-
$(top_srcdir)/case_utils/local_uuid.py \
210206
$(top_srcdir)/case_utils/namespace.py \
211207
sample.txt.done.log
212208
rm -f _$@
213-
export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
209+
export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \
214210
&& source $(tests_srcdir)/venv/bin/activate \
215211
&& case_file \
216212
--debug \

tests/case_utils/test_local_uuid.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)