Skip to content

Commit 8663452

Browse files
committed
Adjust documentation of exposed API
I stumbled across this being a potential point of confusion in the Exifread mapping repository's PR 21. References: * casework/CASE-Implementation-PyPI-Exifread#21 Signed-off-by: Alex Nelson <[email protected]>
1 parent 0cfe6d1 commit 8663452

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

case_utils/local_uuid.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

1414
"""
1515
This library is a wrapper for uuid, provided to generate repeatable UUIDs if requested.
16+
17+
The function local_uuid() should be used in code where a user could be expected to opt in to non-random UUIDs.
1618
"""
1719

1820
__version__ = "0.3.2"
1921

22+
__all__ = ["configure", "local_uuid"]
23+
2024
import logging
2125
import os
2226
import pathlib
@@ -34,13 +38,13 @@
3438

3539
def configure() -> None:
3640
"""
37-
This function is part of setting up demo_uuid() to generate non-random UUIDs. See demo_uuid() documentation for further setup notes.
41+
This function is part of setting up _demo_uuid() to generate non-random UUIDs. See _demo_uuid() documentation for further setup notes.
3842
"""
3943
global DEMO_UUID_BASE
4044

4145
if os.getenv("DEMO_UUID_REQUESTING_NONRANDOM") == "NONRANDOM_REQUESTED":
4246
warnings.warn(
43-
"Environment variable DEMO_UUID_REQUESTING_NONRANDOM is deprecated. See case_utils.local_uuid.demo_uuid for usage notes on its replacement, CASE_DEMO_NONRANDOM_UUID_BASE. Proceeding with random UUIDs.",
47+
"Environment variable DEMO_UUID_REQUESTING_NONRANDOM is deprecated. See case_utils.local_uuid._demo_uuid for usage notes on its replacement, CASE_DEMO_NONRANDOM_UUID_BASE. Proceeding with random UUIDs.",
4448
FutureWarning,
4549
)
4650
return
@@ -109,10 +113,12 @@ def configure() -> None:
109113
DEMO_UUID_BASE = "/".join(demo_uuid_base_parts)
110114

111115

112-
def demo_uuid() -> str:
116+
def _demo_uuid() -> str:
113117
"""
114118
This function generates a repeatable UUID, drawing on non-varying elements of the environment and process call for entropy.
115119
120+
This function is not intended to be called outside of this module. Instead, local_uuid() should be called.
121+
116122
WARNING: This function was developed for use ONLY for reducing (but not eliminating) version-control edits to identifiers when generating sample data. It creates UUIDs that are decidedly NOT random, and should remain consistent on repeated calls to the importing script.
117123
118124
To prevent accidental non-random UUID usage, two setup steps need to be done before calling this function:
@@ -148,4 +154,4 @@ def local_uuid() -> str:
148154
if DEMO_UUID_BASE is None:
149155
return str(uuid.uuid4())
150156
else:
151-
return demo_uuid()
157+
return _demo_uuid()

0 commit comments

Comments
 (0)