|
13 | 13 |
|
14 | 14 | """ |
15 | 15 | 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. |
16 | 18 | """ |
17 | 19 |
|
18 | 20 | __version__ = "0.3.2" |
19 | 21 |
|
| 22 | +__all__ = ["configure", "local_uuid"] |
| 23 | + |
20 | 24 | import logging |
21 | 25 | import os |
22 | 26 | import pathlib |
|
34 | 38 |
|
35 | 39 | def configure() -> None: |
36 | 40 | """ |
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. |
38 | 42 | """ |
39 | 43 | global DEMO_UUID_BASE |
40 | 44 |
|
41 | 45 | if os.getenv("DEMO_UUID_REQUESTING_NONRANDOM") == "NONRANDOM_REQUESTED": |
42 | 46 | 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.", |
44 | 48 | FutureWarning, |
45 | 49 | ) |
46 | 50 | return |
@@ -109,10 +113,12 @@ def configure() -> None: |
109 | 113 | DEMO_UUID_BASE = "/".join(demo_uuid_base_parts) |
110 | 114 |
|
111 | 115 |
|
112 | | -def demo_uuid() -> str: |
| 116 | +def _demo_uuid() -> str: |
113 | 117 | """ |
114 | 118 | This function generates a repeatable UUID, drawing on non-varying elements of the environment and process call for entropy. |
115 | 119 |
|
| 120 | + This function is not intended to be called outside of this module. Instead, local_uuid() should be called. |
| 121 | +
|
116 | 122 | 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. |
117 | 123 |
|
118 | 124 | 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: |
148 | 154 | if DEMO_UUID_BASE is None: |
149 | 155 | return str(uuid.uuid4()) |
150 | 156 | else: |
151 | | - return demo_uuid() |
| 157 | + return _demo_uuid() |
0 commit comments