uuid-kit 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- uuid_kit-1.0.1/LICENSE +21 -0
- uuid_kit-1.0.1/PKG-INFO +209 -0
- uuid_kit-1.0.1/README.md +191 -0
- uuid_kit-1.0.1/pyproject.toml +34 -0
- uuid_kit-1.0.1/setup.cfg +4 -0
- uuid_kit-1.0.1/uuid_kit/__init__.py +5 -0
- uuid_kit-1.0.1/uuid_kit/core.py +171 -0
- uuid_kit-1.0.1/uuid_kit.egg-info/PKG-INFO +209 -0
- uuid_kit-1.0.1/uuid_kit.egg-info/SOURCES.txt +10 -0
- uuid_kit-1.0.1/uuid_kit.egg-info/dependency_links.txt +1 -0
- uuid_kit-1.0.1/uuid_kit.egg-info/requires.txt +1 -0
- uuid_kit-1.0.1/uuid_kit.egg-info/top_level.txt +1 -0
uuid_kit-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Troy Tessalone
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
uuid_kit-1.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uuid-kit
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Generate UUID values (v4, v7) with flexible formatting and structured output options.
|
|
5
|
+
Author: Troy Tessalone
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/troytessalone/uuid-kit
|
|
8
|
+
Project-URL: Issues, https://github.com/troytessalone/uuid-kit/issues
|
|
9
|
+
Keywords: uuid,uuidv4,uuidv7,generator,utility,formatting
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: uuid6>=2024.7.10
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# uuid-kit
|
|
20
|
+
|
|
21
|
+
Generate UUID values (v4, v7) with flexible formatting and structured output options.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install uuid-kit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from uuid_kit import generate_uuid
|
|
37
|
+
|
|
38
|
+
result = generate_uuid(
|
|
39
|
+
count=3,
|
|
40
|
+
version="v7"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
print(result)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Output
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"version": "v7",
|
|
53
|
+
"count": 3,
|
|
54
|
+
"format": "standard",
|
|
55
|
+
"items": [
|
|
56
|
+
"uuid-1",
|
|
57
|
+
"uuid-2",
|
|
58
|
+
"uuid-3"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Options
|
|
66
|
+
|
|
67
|
+
| Field | Type | Required | Default | Description |
|
|
68
|
+
|------|------|----------|---------|-------------|
|
|
69
|
+
| count | int | No | 1 | Number of UUIDs to generate (min 1, max 100) |
|
|
70
|
+
| version | string | No | v7 | UUID version: v4 or v7 |
|
|
71
|
+
| format | string | No | standard | Output format: standard, compact, uppercase, uppercase-compact |
|
|
72
|
+
| prefix | string | No | "" | Text to prepend to each UUID |
|
|
73
|
+
| suffix | string | No | "" | Text to append to each UUID |
|
|
74
|
+
| asObjects | bool | No | False | Return structured objects instead of strings |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Formats
|
|
79
|
+
|
|
80
|
+
| Format | Example |
|
|
81
|
+
|------|------|
|
|
82
|
+
| standard | `123e4567-e89b-12d3-a456-426614174000` |
|
|
83
|
+
| compact | `123e4567e89b12d3a456426614174000` |
|
|
84
|
+
| uppercase | `123E4567-E89B-12D3-A456-426614174000` |
|
|
85
|
+
| uppercase-compact | `123E4567E89B12D3A456426614174000` |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Examples
|
|
90
|
+
|
|
91
|
+
### Default (v7)
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
generate_uuid(count=2)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### v4
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
generate_uuid(count=2, version="v4")
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Compact format
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
generate_uuid(count=2, format="compact")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Uppercase compact with prefix and suffix
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
generate_uuid(
|
|
113
|
+
count=2,
|
|
114
|
+
format="uppercase-compact",
|
|
115
|
+
prefix="id_",
|
|
116
|
+
suffix="_end"
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Return objects
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
generate_uuid(count=2, asObjects=True)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Example output:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"version": "v7",
|
|
131
|
+
"count": 2,
|
|
132
|
+
"format": "standard",
|
|
133
|
+
"items": [
|
|
134
|
+
{
|
|
135
|
+
"uuid": "123e4567-e89b-12d3-a456-426614174000",
|
|
136
|
+
"raw": "123e4567-e89b-12d3-a456-426614174000",
|
|
137
|
+
"index": 0,
|
|
138
|
+
"timestamp": {
|
|
139
|
+
"iso": "2026-04-09T18:00:00Z",
|
|
140
|
+
"unix": 1775757600000
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"uuid": "123e4567-e89b-12d3-a456-426614174001",
|
|
145
|
+
"raw": "123e4567-e89b-12d3-a456-426614174001",
|
|
146
|
+
"index": 1,
|
|
147
|
+
"timestamp": {
|
|
148
|
+
"iso": "2026-04-09T18:00:00Z",
|
|
149
|
+
"unix": 1775757600001
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Supported Versions
|
|
159
|
+
|
|
160
|
+
- v4 = random
|
|
161
|
+
- v7 = modern time-based
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Exports
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from uuid_kit import generate_uuid
|
|
169
|
+
from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Environment Notes
|
|
175
|
+
|
|
176
|
+
Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
uuid-kit
|
|
180
|
+
uuid6
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Behavior
|
|
186
|
+
|
|
187
|
+
- Invalid or missing `count` defaults to 1
|
|
188
|
+
- `count` is capped at 100
|
|
189
|
+
- Invalid or missing `version` defaults to `v7`
|
|
190
|
+
- Invalid or missing `format` defaults to `standard`
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Notes
|
|
195
|
+
|
|
196
|
+
- Python standard library does not yet include native UUID v7 support
|
|
197
|
+
- To enable true v7 UUIDs, install:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pip install uuid6
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- If `uuid6` is not installed, `version="v7"` falls back internally and will not produce a true v7 UUID
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
uuid_kit-1.0.1/README.md
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# uuid-kit
|
|
2
|
+
|
|
3
|
+
Generate UUID values (v4, v7) with flexible formatting and structured output options.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install uuid-kit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from uuid_kit import generate_uuid
|
|
19
|
+
|
|
20
|
+
result = generate_uuid(
|
|
21
|
+
count=3,
|
|
22
|
+
version="v7"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
print(result)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Output
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"version": "v7",
|
|
35
|
+
"count": 3,
|
|
36
|
+
"format": "standard",
|
|
37
|
+
"items": [
|
|
38
|
+
"uuid-1",
|
|
39
|
+
"uuid-2",
|
|
40
|
+
"uuid-3"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Options
|
|
48
|
+
|
|
49
|
+
| Field | Type | Required | Default | Description |
|
|
50
|
+
|------|------|----------|---------|-------------|
|
|
51
|
+
| count | int | No | 1 | Number of UUIDs to generate (min 1, max 100) |
|
|
52
|
+
| version | string | No | v7 | UUID version: v4 or v7 |
|
|
53
|
+
| format | string | No | standard | Output format: standard, compact, uppercase, uppercase-compact |
|
|
54
|
+
| prefix | string | No | "" | Text to prepend to each UUID |
|
|
55
|
+
| suffix | string | No | "" | Text to append to each UUID |
|
|
56
|
+
| asObjects | bool | No | False | Return structured objects instead of strings |
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Formats
|
|
61
|
+
|
|
62
|
+
| Format | Example |
|
|
63
|
+
|------|------|
|
|
64
|
+
| standard | `123e4567-e89b-12d3-a456-426614174000` |
|
|
65
|
+
| compact | `123e4567e89b12d3a456426614174000` |
|
|
66
|
+
| uppercase | `123E4567-E89B-12D3-A456-426614174000` |
|
|
67
|
+
| uppercase-compact | `123E4567E89B12D3A456426614174000` |
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Examples
|
|
72
|
+
|
|
73
|
+
### Default (v7)
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
generate_uuid(count=2)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### v4
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
generate_uuid(count=2, version="v4")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Compact format
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
generate_uuid(count=2, format="compact")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Uppercase compact with prefix and suffix
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
generate_uuid(
|
|
95
|
+
count=2,
|
|
96
|
+
format="uppercase-compact",
|
|
97
|
+
prefix="id_",
|
|
98
|
+
suffix="_end"
|
|
99
|
+
)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Return objects
|
|
103
|
+
|
|
104
|
+
```python
|
|
105
|
+
generate_uuid(count=2, asObjects=True)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Example output:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"version": "v7",
|
|
113
|
+
"count": 2,
|
|
114
|
+
"format": "standard",
|
|
115
|
+
"items": [
|
|
116
|
+
{
|
|
117
|
+
"uuid": "123e4567-e89b-12d3-a456-426614174000",
|
|
118
|
+
"raw": "123e4567-e89b-12d3-a456-426614174000",
|
|
119
|
+
"index": 0,
|
|
120
|
+
"timestamp": {
|
|
121
|
+
"iso": "2026-04-09T18:00:00Z",
|
|
122
|
+
"unix": 1775757600000
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"uuid": "123e4567-e89b-12d3-a456-426614174001",
|
|
127
|
+
"raw": "123e4567-e89b-12d3-a456-426614174001",
|
|
128
|
+
"index": 1,
|
|
129
|
+
"timestamp": {
|
|
130
|
+
"iso": "2026-04-09T18:00:00Z",
|
|
131
|
+
"unix": 1775757600001
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Supported Versions
|
|
141
|
+
|
|
142
|
+
- v4 = random
|
|
143
|
+
- v7 = modern time-based
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Exports
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from uuid_kit import generate_uuid
|
|
151
|
+
from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Environment Notes
|
|
157
|
+
|
|
158
|
+
Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
uuid-kit
|
|
162
|
+
uuid6
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Behavior
|
|
168
|
+
|
|
169
|
+
- Invalid or missing `count` defaults to 1
|
|
170
|
+
- `count` is capped at 100
|
|
171
|
+
- Invalid or missing `version` defaults to `v7`
|
|
172
|
+
- Invalid or missing `format` defaults to `standard`
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Notes
|
|
177
|
+
|
|
178
|
+
- Python standard library does not yet include native UUID v7 support
|
|
179
|
+
- To enable true v7 UUIDs, install:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
pip install uuid6
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- If `uuid6` is not installed, `version="v7"` falls back internally and will not produce a true v7 UUID
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "uuid-kit"
|
|
7
|
+
version = "1.0.1"
|
|
8
|
+
description = "Generate UUID values (v4, v7) with flexible formatting and structured output options."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Troy Tessalone" }
|
|
12
|
+
]
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
requires-python = ">=3.8"
|
|
15
|
+
dependencies = ["uuid6>=2024.7.10"]
|
|
16
|
+
|
|
17
|
+
keywords = [
|
|
18
|
+
"uuid",
|
|
19
|
+
"uuidv4",
|
|
20
|
+
"uuidv7",
|
|
21
|
+
"generator",
|
|
22
|
+
"utility",
|
|
23
|
+
"formatting"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
classifiers = [
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"License :: OSI Approved :: MIT License",
|
|
29
|
+
"Operating System :: OS Independent"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://github.com/troytessalone/uuid-kit"
|
|
34
|
+
Issues = "https://github.com/troytessalone/uuid-kit/issues"
|
uuid_kit-1.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# py/uuid_kit/core.py
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import uuid
|
|
5
|
+
|
|
6
|
+
_uuid7_fn = None
|
|
7
|
+
|
|
8
|
+
try:
|
|
9
|
+
uuid6_module = importlib.import_module("uuid6")
|
|
10
|
+
_uuid7_fn = uuid6_module.uuid7
|
|
11
|
+
HAS_UUID7 = True
|
|
12
|
+
except Exception:
|
|
13
|
+
HAS_UUID7 = False
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
ALLOWED_FORMATS = (
|
|
17
|
+
"standard",
|
|
18
|
+
"compact",
|
|
19
|
+
"uppercase",
|
|
20
|
+
"uppercase-compact"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
ALLOWED_VERSIONS = (
|
|
24
|
+
"v4",
|
|
25
|
+
"v7"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_formatter(format_value):
|
|
30
|
+
if format_value == "compact":
|
|
31
|
+
return lambda v: v.replace("-", "")
|
|
32
|
+
if format_value == "uppercase":
|
|
33
|
+
return lambda v: v.upper()
|
|
34
|
+
if format_value == "uppercase-compact":
|
|
35
|
+
return lambda v: v.replace("-", "").upper()
|
|
36
|
+
return lambda v: v
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def extract_timestamp_v7(uuid_value):
|
|
40
|
+
hex_value = uuid_value.replace("-", "")[:12]
|
|
41
|
+
ms = int(hex_value, 16)
|
|
42
|
+
|
|
43
|
+
from datetime import datetime, timezone
|
|
44
|
+
|
|
45
|
+
dt = datetime.fromtimestamp(ms / 1000, tz=timezone.utc)
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
"iso": dt.isoformat().replace("+00:00", "Z"),
|
|
49
|
+
"unix": ms
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def generate_uuid(
|
|
54
|
+
count=1,
|
|
55
|
+
version="v7",
|
|
56
|
+
format="standard",
|
|
57
|
+
prefix="",
|
|
58
|
+
suffix="",
|
|
59
|
+
asObjects=False
|
|
60
|
+
):
|
|
61
|
+
"""
|
|
62
|
+
Generate UUID values.
|
|
63
|
+
|
|
64
|
+
:param count: number of UUIDs (min 1, max 100)
|
|
65
|
+
:param version: "v4" or "v7"
|
|
66
|
+
:param format: "standard", "compact", "uppercase", or "uppercase-compact"
|
|
67
|
+
:param prefix: string to prepend to each UUID
|
|
68
|
+
:param suffix: string to append to each UUID
|
|
69
|
+
:param asObjects: if True, return structured item objects
|
|
70
|
+
:return: dict
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
# ===============================
|
|
74
|
+
# VALIDATE COUNT
|
|
75
|
+
# ===============================
|
|
76
|
+
try:
|
|
77
|
+
safe_count = float(count)
|
|
78
|
+
except Exception:
|
|
79
|
+
safe_count = 1
|
|
80
|
+
|
|
81
|
+
if safe_count != safe_count or safe_count < 0:
|
|
82
|
+
safe_count = 1
|
|
83
|
+
if safe_count > 100:
|
|
84
|
+
safe_count = 100
|
|
85
|
+
|
|
86
|
+
safe_count = int(safe_count)
|
|
87
|
+
|
|
88
|
+
# ===============================
|
|
89
|
+
# VALIDATE VERSION
|
|
90
|
+
# ===============================
|
|
91
|
+
normalized_version = str(version or "v7").lower()
|
|
92
|
+
final_version = normalized_version if normalized_version in ALLOWED_VERSIONS else "v7"
|
|
93
|
+
|
|
94
|
+
# ===============================
|
|
95
|
+
# VALIDATE FORMAT
|
|
96
|
+
# ===============================
|
|
97
|
+
normalized_format = str(format or "standard").lower()
|
|
98
|
+
final_format = normalized_format if normalized_format in ALLOWED_FORMATS else "standard"
|
|
99
|
+
|
|
100
|
+
formatter = get_formatter(final_format)
|
|
101
|
+
|
|
102
|
+
# ===============================
|
|
103
|
+
# VERSION CONFIG
|
|
104
|
+
# ===============================
|
|
105
|
+
def generate_v4():
|
|
106
|
+
return str(uuid.uuid4())
|
|
107
|
+
|
|
108
|
+
def generate_v7():
|
|
109
|
+
if HAS_UUID7 and _uuid7_fn:
|
|
110
|
+
return str(_uuid7_fn())
|
|
111
|
+
return str(uuid.uuid4())
|
|
112
|
+
|
|
113
|
+
version_config = {
|
|
114
|
+
"v4": {
|
|
115
|
+
"generator": generate_v4,
|
|
116
|
+
"hasTimestamp": False,
|
|
117
|
+
"extractTimestamp": None
|
|
118
|
+
},
|
|
119
|
+
"v7": {
|
|
120
|
+
"generator": generate_v7,
|
|
121
|
+
"hasTimestamp": True,
|
|
122
|
+
"extractTimestamp": extract_timestamp_v7
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
generator = version_config[final_version]["generator"]
|
|
127
|
+
has_timestamp = version_config[final_version]["hasTimestamp"]
|
|
128
|
+
extract_timestamp = version_config[final_version]["extractTimestamp"]
|
|
129
|
+
|
|
130
|
+
# ===============================
|
|
131
|
+
# GENERATE
|
|
132
|
+
# ===============================
|
|
133
|
+
items = []
|
|
134
|
+
|
|
135
|
+
for i in range(safe_count):
|
|
136
|
+
raw = generator()
|
|
137
|
+
|
|
138
|
+
timestamp = None
|
|
139
|
+
if has_timestamp and extract_timestamp:
|
|
140
|
+
try:
|
|
141
|
+
timestamp = extract_timestamp(raw)
|
|
142
|
+
except Exception:
|
|
143
|
+
timestamp = None
|
|
144
|
+
|
|
145
|
+
value = formatter(raw)
|
|
146
|
+
|
|
147
|
+
if prefix:
|
|
148
|
+
value = str(prefix) + value
|
|
149
|
+
if suffix:
|
|
150
|
+
value = value + str(suffix)
|
|
151
|
+
|
|
152
|
+
if asObjects:
|
|
153
|
+
obj = {
|
|
154
|
+
"uuid": value,
|
|
155
|
+
"raw": raw,
|
|
156
|
+
"index": i
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if timestamp:
|
|
160
|
+
obj["timestamp"] = timestamp
|
|
161
|
+
|
|
162
|
+
items.append(obj)
|
|
163
|
+
else:
|
|
164
|
+
items.append(value)
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
"version": final_version,
|
|
168
|
+
"format": final_format,
|
|
169
|
+
"count": safe_count,
|
|
170
|
+
"items": items
|
|
171
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uuid-kit
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Generate UUID values (v4, v7) with flexible formatting and structured output options.
|
|
5
|
+
Author: Troy Tessalone
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/troytessalone/uuid-kit
|
|
8
|
+
Project-URL: Issues, https://github.com/troytessalone/uuid-kit/issues
|
|
9
|
+
Keywords: uuid,uuidv4,uuidv7,generator,utility,formatting
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: uuid6>=2024.7.10
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# uuid-kit
|
|
20
|
+
|
|
21
|
+
Generate UUID values (v4, v7) with flexible formatting and structured output options.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install uuid-kit
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from uuid_kit import generate_uuid
|
|
37
|
+
|
|
38
|
+
result = generate_uuid(
|
|
39
|
+
count=3,
|
|
40
|
+
version="v7"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
print(result)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Output
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"version": "v7",
|
|
53
|
+
"count": 3,
|
|
54
|
+
"format": "standard",
|
|
55
|
+
"items": [
|
|
56
|
+
"uuid-1",
|
|
57
|
+
"uuid-2",
|
|
58
|
+
"uuid-3"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Options
|
|
66
|
+
|
|
67
|
+
| Field | Type | Required | Default | Description |
|
|
68
|
+
|------|------|----------|---------|-------------|
|
|
69
|
+
| count | int | No | 1 | Number of UUIDs to generate (min 1, max 100) |
|
|
70
|
+
| version | string | No | v7 | UUID version: v4 or v7 |
|
|
71
|
+
| format | string | No | standard | Output format: standard, compact, uppercase, uppercase-compact |
|
|
72
|
+
| prefix | string | No | "" | Text to prepend to each UUID |
|
|
73
|
+
| suffix | string | No | "" | Text to append to each UUID |
|
|
74
|
+
| asObjects | bool | No | False | Return structured objects instead of strings |
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Formats
|
|
79
|
+
|
|
80
|
+
| Format | Example |
|
|
81
|
+
|------|------|
|
|
82
|
+
| standard | `123e4567-e89b-12d3-a456-426614174000` |
|
|
83
|
+
| compact | `123e4567e89b12d3a456426614174000` |
|
|
84
|
+
| uppercase | `123E4567-E89B-12D3-A456-426614174000` |
|
|
85
|
+
| uppercase-compact | `123E4567E89B12D3A456426614174000` |
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Examples
|
|
90
|
+
|
|
91
|
+
### Default (v7)
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
generate_uuid(count=2)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### v4
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
generate_uuid(count=2, version="v4")
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Compact format
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
generate_uuid(count=2, format="compact")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Uppercase compact with prefix and suffix
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
generate_uuid(
|
|
113
|
+
count=2,
|
|
114
|
+
format="uppercase-compact",
|
|
115
|
+
prefix="id_",
|
|
116
|
+
suffix="_end"
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Return objects
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
generate_uuid(count=2, asObjects=True)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Example output:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"version": "v7",
|
|
131
|
+
"count": 2,
|
|
132
|
+
"format": "standard",
|
|
133
|
+
"items": [
|
|
134
|
+
{
|
|
135
|
+
"uuid": "123e4567-e89b-12d3-a456-426614174000",
|
|
136
|
+
"raw": "123e4567-e89b-12d3-a456-426614174000",
|
|
137
|
+
"index": 0,
|
|
138
|
+
"timestamp": {
|
|
139
|
+
"iso": "2026-04-09T18:00:00Z",
|
|
140
|
+
"unix": 1775757600000
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"uuid": "123e4567-e89b-12d3-a456-426614174001",
|
|
145
|
+
"raw": "123e4567-e89b-12d3-a456-426614174001",
|
|
146
|
+
"index": 1,
|
|
147
|
+
"timestamp": {
|
|
148
|
+
"iso": "2026-04-09T18:00:00Z",
|
|
149
|
+
"unix": 1775757600001
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Supported Versions
|
|
159
|
+
|
|
160
|
+
- v4 = random
|
|
161
|
+
- v7 = modern time-based
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Exports
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from uuid_kit import generate_uuid
|
|
169
|
+
from uuid_kit import ALLOWED_FORMATS, ALLOWED_VERSIONS
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Environment Notes
|
|
175
|
+
|
|
176
|
+
Some hosted Python runtimes require you to explicitly add packages before use. In those environments, add:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
uuid-kit
|
|
180
|
+
uuid6
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
---
|
|
184
|
+
|
|
185
|
+
## Behavior
|
|
186
|
+
|
|
187
|
+
- Invalid or missing `count` defaults to 1
|
|
188
|
+
- `count` is capped at 100
|
|
189
|
+
- Invalid or missing `version` defaults to `v7`
|
|
190
|
+
- Invalid or missing `format` defaults to `standard`
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Notes
|
|
195
|
+
|
|
196
|
+
- Python standard library does not yet include native UUID v7 support
|
|
197
|
+
- To enable true v7 UUIDs, install:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
pip install uuid6
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- If `uuid6` is not installed, `version="v7"` falls back internally and will not produce a true v7 UUID
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## License
|
|
208
|
+
|
|
209
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uuid6>=2024.7.10
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uuid_kit
|