diff --git a/case_utils/__init__.py b/case_utils/__init__.py index 898dacd..8202837 100644 --- a/case_utils/__init__.py +++ b/case_utils/__init__.py @@ -15,5 +15,3 @@ # We would appreciate acknowledgement if the software is used. __version__ = "0.14.1.post0" - -from . import local_uuid # noqa: F401 diff --git a/case_utils/case_file/__init__.py b/case_utils/case_file/__init__.py index 5f797fc..313acc6 100644 --- a/case_utils/case_file/__init__.py +++ b/case_utils/case_file/__init__.py @@ -28,7 +28,9 @@ import typing import warnings +import cdo_local_uuid import rdflib +from cdo_local_uuid import local_uuid import case_utils.inherent_uuid from case_utils.namespace import ( @@ -94,7 +96,7 @@ def create_file_node( node_namespace = rdflib.Namespace(node_prefix) if node_iri is None: - node_slug = "File-" + case_utils.local_uuid.local_uuid() + node_slug = "File-" + local_uuid() node_iri = node_namespace[node_slug] n_file = rdflib.URIRef(node_iri) graph.add((n_file, NS_RDF.type, NS_UCO_OBSERVABLE.File)) @@ -110,7 +112,7 @@ def create_file_node( n_file, NS_UCO_OBSERVABLE.FileFacet, namespace=node_namespace ) else: - n_file_facet = node_namespace["FileFacet-" + case_utils.local_uuid.local_uuid()] + n_file_facet = node_namespace["FileFacet-" + local_uuid()] graph.add( ( @@ -144,9 +146,7 @@ def create_file_node( n_file, NS_UCO_OBSERVABLE.ContentDataFacet, namespace=node_namespace ) else: - n_contentdata_facet = node_namespace[ - "ContentDataFacet-" + case_utils.local_uuid.local_uuid() - ] + n_contentdata_facet = node_namespace["ContentDataFacet-" + local_uuid()] graph.add((n_file, NS_UCO_CORE.hasFacet, n_contentdata_facet)) graph.add( @@ -248,7 +248,7 @@ def create_file_node( ) ) else: - hash_uuid = case_utils.local_uuid.local_uuid() + hash_uuid = local_uuid() n_hash = node_namespace["Hash-" + hash_uuid] graph.add((n_contentdata_facet, NS_UCO_OBSERVABLE.hash, n_hash)) @@ -291,7 +291,7 @@ def main() -> None: logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO) - case_utils.local_uuid.configure() + cdo_local_uuid.configure() NS_BASE = rdflib.Namespace(args.base_prefix) @@ -314,7 +314,7 @@ def main() -> None: context_dictionary = {k: v for (k, v) in graph.namespace_manager.namespaces()} serialize_kwargs["context"] = context_dictionary - node_iri = NS_BASE["File-" + case_utils.local_uuid.local_uuid()] + node_iri = NS_BASE["File-" + local_uuid()] create_file_node( graph, args.in_file, diff --git a/case_utils/inherent_uuid.py b/case_utils/inherent_uuid.py index cdcba73..92c2056 100644 --- a/case_utils/inherent_uuid.py +++ b/case_utils/inherent_uuid.py @@ -23,7 +23,7 @@ 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. 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. -This module is independent of, and complements, `case_utils.local_uuid`, which provides deterministic UUIDs based on calling process's environment. +This module is independent of, and complements, `cdo_local_uuid.local_uuid`, which provides deterministic UUIDs based on calling process's environment. References ========== diff --git a/setup.cfg b/setup.cfg index e40529f..38c1230 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,7 +19,7 @@ license_files = [options] include_package_data = true install_requires = - cdo-local-uuid >= 0.4.0, < 0.5.0 + cdo-local-uuid >= 0.5.0, < 0.6.0 pandas pyshacl >= 0.24.0 rdflib < 8 diff --git a/tests/case_utils/case_file/Makefile b/tests/case_utils/case_file/Makefile index d65fb40..742315c 100644 --- a/tests/case_utils/case_file/Makefile +++ b/tests/case_utils/case_file/Makefile @@ -117,11 +117,10 @@ sample.txt.json: \ $(tests_srcdir)/src/isomorphic_diff.py \ $(top_srcdir)/case_utils/case_file/__init__.py \ $(top_srcdir)/case_utils/inherent_uuid.py \ - $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt-nocompact.json rm -f $@ _$@ __$@ - export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ + export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ @@ -152,11 +151,10 @@ sample.txt.ttl: \ $(tests_srcdir)/.venv.done.log \ $(top_srcdir)/case_utils/case_file/__init__.py \ $(top_srcdir)/case_utils/inherent_uuid.py \ - $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt.done.log rm -f _$@ __$@ - export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ + export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ @@ -178,11 +176,10 @@ sample.txt-disable_hashes.ttl: \ $(tests_srcdir)/.venv.done.log \ $(top_srcdir)/case_utils/case_file/__init__.py \ $(top_srcdir)/case_utils/inherent_uuid.py \ - $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt.done.log rm -f _$@ __$@ - export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ + export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ @@ -206,11 +203,10 @@ sample.txt-nocompact.json: \ $(tests_srcdir)/src/isomorphic_diff.py \ $(top_srcdir)/case_utils/case_file/__init__.py \ $(top_srcdir)/case_utils/inherent_uuid.py \ - $(top_srcdir)/case_utils/local_uuid.py \ $(top_srcdir)/case_utils/namespace.py \ sample.txt.done.log rm -f _$@ - export CASE_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ + export CDO_DEMO_NONRANDOM_UUID_BASE="$(top_srcdir)" \ && source $(tests_srcdir)/venv/bin/activate \ && case_file \ --debug \ diff --git a/tests/case_utils/test_local_uuid.py b/tests/case_utils/test_local_uuid.py deleted file mode 100644 index 40969fb..0000000 --- a/tests/case_utils/test_local_uuid.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -# Portions of this file contributed by NIST are governed by the following -# statement: -# -# This software was developed at the National Institute of Standards -# and Technology by employees of the Federal Government in the course -# of their official duties. Pursuant to Title 17 Section 105 of the -# United States Code, this software is not subject to copyright -# protection within the United States. NIST assumes no responsibility -# whatsoever for its use by other parties, and makes no guarantees, -# expressed or implied, about its quality, reliability, or any other -# characteristic. -# -# We would appreciate acknowledgement if the software is used. - -import pytest - -import case_utils.local_uuid - - -def test_local_uuid_deprecation(monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setenv("DEMO_UUID_REQUESTING_NONRANDOM", "NONRANDOM_REQUESTED") - with pytest.warns(FutureWarning): - case_utils.local_uuid.configure() - - -def test_local_uuid_nondirectory(monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setenv("CASE_DEMO_NONRANDOM_UUID_BASE", "/dev/null") - with pytest.warns(RuntimeWarning): - case_utils.local_uuid.configure() - - -def test_local_uuid_nonexistent(monkeypatch: pytest.MonkeyPatch) -> None: - monkeypatch.setenv("CASE_DEMO_NONRANDOM_UUID_BASE", "/dev/nonexistent") - with pytest.warns(RuntimeWarning): - case_utils.local_uuid.configure()