utilix-sdk 0.1.0__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.
- utilix_sdk-0.1.0/.hypothesis/unicode_data/16.0.0/charmap.json.gz +0 -0
- utilix_sdk-0.1.0/LICENSE +21 -0
- utilix_sdk-0.1.0/PKG-INFO +325 -0
- utilix_sdk-0.1.0/README.md +277 -0
- utilix_sdk-0.1.0/pyproject.toml +75 -0
- utilix_sdk-0.1.0/src/utilix/__init__.py +32 -0
- utilix_sdk-0.1.0/src/utilix/tools/__init__.py +1 -0
- utilix_sdk-0.1.0/src/utilix/tools/api_tools.py +1325 -0
- utilix_sdk-0.1.0/src/utilix/tools/code.py +2639 -0
- utilix_sdk-0.1.0/src/utilix/tools/color.py +956 -0
- utilix_sdk-0.1.0/src/utilix/tools/css.py +1082 -0
- utilix_sdk-0.1.0/src/utilix/tools/data.py +1224 -0
- utilix_sdk-0.1.0/src/utilix/tools/encoding.py +375 -0
- utilix_sdk-0.1.0/src/utilix/tools/generators.py +506 -0
- utilix_sdk-0.1.0/src/utilix/tools/hashing.py +232 -0
- utilix_sdk-0.1.0/src/utilix/tools/json_tools.py +873 -0
- utilix_sdk-0.1.0/src/utilix/tools/media.py +401 -0
- utilix_sdk-0.1.0/src/utilix/tools/misc.py +1096 -0
- utilix_sdk-0.1.0/src/utilix/tools/network.py +528 -0
- utilix_sdk-0.1.0/src/utilix/tools/text.py +1338 -0
- utilix_sdk-0.1.0/src/utilix/tools/time_tools.py +898 -0
- utilix_sdk-0.1.0/src/utilix/tools/units.py +696 -0
- utilix_sdk-0.1.0/tests/__init__.py +0 -0
- utilix_sdk-0.1.0/tests/conftest.py +2 -0
- utilix_sdk-0.1.0/tests/test_api_tools.py +1151 -0
- utilix_sdk-0.1.0/tests/test_code.py +1150 -0
- utilix_sdk-0.1.0/tests/test_color.py +693 -0
- utilix_sdk-0.1.0/tests/test_css.py +1126 -0
- utilix_sdk-0.1.0/tests/test_data.py +611 -0
- utilix_sdk-0.1.0/tests/test_encoding.py +490 -0
- utilix_sdk-0.1.0/tests/test_generators.py +510 -0
- utilix_sdk-0.1.0/tests/test_hashing.py +475 -0
- utilix_sdk-0.1.0/tests/test_json_tools.py +626 -0
- utilix_sdk-0.1.0/tests/test_media.py +395 -0
- utilix_sdk-0.1.0/tests/test_misc.py +750 -0
- utilix_sdk-0.1.0/tests/test_network.py +845 -0
- utilix_sdk-0.1.0/tests/test_text.py +934 -0
- utilix_sdk-0.1.0/tests/test_time_tools.py +685 -0
- utilix_sdk-0.1.0/tests/test_units.py +592 -0
|
Binary file
|
utilix_sdk-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Utilix
|
|
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.
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: utilix-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: 100+ developer utility tools for Python — JSON, encoding, hashing, color, CSS, images, network and more
|
|
5
|
+
Project-URL: Homepage, https://utilix.tech
|
|
6
|
+
Project-URL: Documentation, https://docs.utilix.tech/sdk/python
|
|
7
|
+
Project-URL: Repository, https://github.com/utilix-tech/utilix-sdk-python
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/utilix-tech/utilix-sdk-python/issues
|
|
9
|
+
Project-URL: Changelog, https://utilix.tech/changelog
|
|
10
|
+
Author-email: Utilix <hello@utilix.tech>
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: color,css,developer-tools,devtools,encoding,hashing,image,json,network,sdk,utilities
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: bcrypt>=4.0
|
|
23
|
+
Requires-Dist: beautifulsoup4>=4.12
|
|
24
|
+
Requires-Dist: croniter>=2.0
|
|
25
|
+
Requires-Dist: jsonpath-ng>=1.6
|
|
26
|
+
Requires-Dist: jsonschema>=4.0
|
|
27
|
+
Requires-Dist: lxml>=5.0
|
|
28
|
+
Requires-Dist: markdown>=3.5
|
|
29
|
+
Requires-Dist: markdownify>=0.11
|
|
30
|
+
Requires-Dist: openapi-spec-validator>=0.7
|
|
31
|
+
Requires-Dist: pillow>=10.0
|
|
32
|
+
Requires-Dist: pyjwt>=2.8
|
|
33
|
+
Requires-Dist: python-dateutil>=2.9
|
|
34
|
+
Requires-Dist: pyyaml>=6.0
|
|
35
|
+
Requires-Dist: qrcode>=7.4
|
|
36
|
+
Requires-Dist: requests>=2.31
|
|
37
|
+
Requires-Dist: rjsmin>=1.2
|
|
38
|
+
Requires-Dist: scour>=0.38
|
|
39
|
+
Requires-Dist: semver>=3.0
|
|
40
|
+
Requires-Dist: sqlparse>=0.5
|
|
41
|
+
Requires-Dist: tinycss2>=1.2
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: build>=1.0; extra == 'dev'
|
|
44
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
45
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
46
|
+
Requires-Dist: twine>=5.0; extra == 'dev'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
# utilix-sdk
|
|
50
|
+
|
|
51
|
+
**100+ developer utility tools for Python — runs entirely locally, no API key required.**
|
|
52
|
+
|
|
53
|
+
[](https://pypi.org/project/utilix-sdk/)
|
|
54
|
+
[](https://www.python.org/downloads/)
|
|
55
|
+
[](LICENSE)
|
|
56
|
+
[](https://github.com/utilix-tech/utilix-sdk-python/actions)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install utilix-sdk
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Requires Python 3.11 or later.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Quick Start
|
|
71
|
+
|
|
72
|
+
### Encoding
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from utilix.tools.encoding import encode_base64, decode_base64
|
|
76
|
+
|
|
77
|
+
result = encode_base64("hello world")
|
|
78
|
+
# {"ok": True, "output": "aGVsbG8gd29ybGQ=", "inputBytes": 11, "outputChars": 16}
|
|
79
|
+
|
|
80
|
+
result = decode_base64("aGVsbG8gd29ybGQ=")
|
|
81
|
+
# {"ok": True, "output": "hello world", "outputBytes": 11}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Hashing
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from utilix.tools.hashing import hash_all, hash_one
|
|
88
|
+
|
|
89
|
+
result = hash_all("my-secret")
|
|
90
|
+
# Returns MD5, SHA-1, SHA-256, SHA-384, SHA-512 digests in one call
|
|
91
|
+
|
|
92
|
+
sha256 = hash_one("SHA-256", "my-secret")
|
|
93
|
+
# {"ok": True, "algorithm": "SHA-256", "hex": "...", "bits": 256}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### JSON Tools
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from utilix.tools.json_tools import format_json, minify_json, yaml_to_json
|
|
100
|
+
|
|
101
|
+
pretty = format_json('{"name":"utilix","version":"0.1.0"}', indent=2)
|
|
102
|
+
# {"status": "valid", "output": "{\n \"name\": \"utilix\", ...", ...}
|
|
103
|
+
|
|
104
|
+
minified = minify_json('{\n "a": 1,\n "b": 2\n}')
|
|
105
|
+
# {"ok": True, "output": "{\"a\":1,\"b\":2}", ...}
|
|
106
|
+
|
|
107
|
+
as_json = yaml_to_json("name: utilix\nversion: 0.1.0")
|
|
108
|
+
# {"ok": True, "output": "{\"name\": \"utilix\", \"version\": \"0.1.0\"}"}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Color
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from utilix.tools.color import hex_to_rgb, check_contrast, generate_palette
|
|
115
|
+
|
|
116
|
+
rgb = hex_to_rgb("#3B82F6")
|
|
117
|
+
# {"ok": True, "r": 59, "g": 130, "b": 246}
|
|
118
|
+
|
|
119
|
+
contrast = check_contrast("#FFFFFF", "#3B82F6")
|
|
120
|
+
# {"ratio": 3.94, "aa_normal": False, "aa_large": True, "aaa_normal": False, ...}
|
|
121
|
+
|
|
122
|
+
palette = generate_palette("#3B82F6", scheme="complementary")
|
|
123
|
+
# Returns list of hex colors forming a complementary palette
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Media
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from utilix.tools.media import compress_image, convert_image
|
|
130
|
+
|
|
131
|
+
with open("photo.jpg", "rb") as f:
|
|
132
|
+
image_bytes = f.read()
|
|
133
|
+
|
|
134
|
+
result = compress_image(image_bytes, quality=75, format="JPEG")
|
|
135
|
+
# {"ok": True, "output": bytes, "original_size": 204800, "compressed_size": 61440, "ratio": 0.3}
|
|
136
|
+
|
|
137
|
+
converted = convert_image(image_bytes, target_format="WEBP")
|
|
138
|
+
# {"ok": True, "output": bytes, "format": "WEBP"}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### CSS
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from utilix.tools.css import generate_gradient, calc_specificity, minify_css
|
|
145
|
+
|
|
146
|
+
gradient = generate_gradient({
|
|
147
|
+
"type": "linear",
|
|
148
|
+
"angle": 135,
|
|
149
|
+
"stops": [{"color": "#667eea", "position": 0}, {"color": "#764ba2", "position": 100}]
|
|
150
|
+
})
|
|
151
|
+
# "linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
|
152
|
+
|
|
153
|
+
specificity = calc_specificity("#nav .item:hover")
|
|
154
|
+
# {"score": (0, 1, 1, 1), "display": "0,1,1,1", "explanation": [...]}
|
|
155
|
+
|
|
156
|
+
minified = minify_css("body {\n margin: 0;\n padding: 0;\n}")
|
|
157
|
+
# {"ok": True, "output": "body{margin:0;padding:0}", "saved_bytes": 14}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Time Tools
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
from utilix.tools.time_tools import from_unix, diff_dates, get_next_runs
|
|
164
|
+
|
|
165
|
+
parsed = from_unix(1735689600)
|
|
166
|
+
# {"ok": True, "iso": "2025-01-01T00:00:00+00:00", "relative": "6 months ago", ...}
|
|
167
|
+
|
|
168
|
+
delta = diff_dates("2024-01-01", "2024-12-31")
|
|
169
|
+
# {"ok": True, "days": 365, "months": 12, "human": "12 months"}
|
|
170
|
+
|
|
171
|
+
schedule = get_next_runs("0 9 * * MON-FRI", count=5)
|
|
172
|
+
# Next 5 weekday 9am runs as ISO strings
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Network
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from utilix.tools.network import ip_to_decimal, cidr_info, is_valid_ipv4
|
|
179
|
+
|
|
180
|
+
decimal = ip_to_decimal("192.168.1.1")
|
|
181
|
+
# {"ok": True, "output": 3232235777}
|
|
182
|
+
|
|
183
|
+
subnet = cidr_info("10.0.0.0/24")
|
|
184
|
+
# {"ok": True, "network": "10.0.0.0", "broadcast": "10.0.0.255",
|
|
185
|
+
# "hosts": 254, "netmask": "255.255.255.0", ...}
|
|
186
|
+
|
|
187
|
+
print(is_valid_ipv4("256.0.0.1")) # False
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Modules
|
|
193
|
+
|
|
194
|
+
| Module | Description |
|
|
195
|
+
|---|---|
|
|
196
|
+
| `encoding` | Base64, Base32, URL encoding/decoding, HTML entity encoding |
|
|
197
|
+
| `hashing` | MD5, SHA-1/256/384/512 digests, bcrypt password hashing, htpasswd |
|
|
198
|
+
| `json_tools` | JSON formatting, minification, diffing, CSV conversion, JSONPath, JSON Schema, YAML-JSON |
|
|
199
|
+
| `color` | Color conversion (hex/RGB/HSL/HSV), palettes, contrast ratios, shades/tints, blending |
|
|
200
|
+
| `css` | Gradients, box shadows, border radius, animations, cubic bezier, clamp, specificity, minifier |
|
|
201
|
+
| `media` | Image compression, format conversion, favicon generation, SVG optimization |
|
|
202
|
+
| `time_tools` | Unix timestamp parsing, cron expression parsing, date diffing, timezone conversion |
|
|
203
|
+
| `network` | IPv4 conversion, CIDR calculator, DNS lookup (DoH), IP geolocation |
|
|
204
|
+
| `api_tools` | cURL builder/parser, cURL-to-code, JWT decode/sign, HTTP status codes, CORS/CSP builders |
|
|
205
|
+
| `code` | Regex tester, SQL formatter, HTML formatter/minifier, GraphQL formatter, semver, URL parser, JS minifier |
|
|
206
|
+
| `data` | YAML, TOML, XML, CSV, INI, and `.env` file parsing, validation, and conversion |
|
|
207
|
+
| `generators` | UUID v4/v7, ULID, password generator, random data, QR code generation |
|
|
208
|
+
| `text` | Word counter, case converter, lorem ipsum, slugifier, string escaping, diff viewer, Markdown/HTML |
|
|
209
|
+
| `misc` | Unicode analysis, ASCII art, Morse code, JSON-to-TypeScript/Go/Python/Zod schema generation |
|
|
210
|
+
| `units` | px/rem/vw conversions, byte formatter, number base conversion, aspect ratio, chmod calculator |
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Surface A vs Surface B
|
|
215
|
+
|
|
216
|
+
### Surface A — this package (`utilix-sdk`)
|
|
217
|
+
|
|
218
|
+
Everything in this package runs **locally in your Python process**. There are no network calls for the core utilities (DNS lookup and IP geolocation are the only exceptions, and both hit public free APIs). No account, no API key, no rate limits.
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
pip install utilix-sdk
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Ideal for: scripts, CI pipelines, offline environments, CLIs, and any situation where you want deterministic, zero-cost utility functions.
|
|
225
|
+
|
|
226
|
+
### Surface B — REST API (`api.utilix.tech/v1`)
|
|
227
|
+
|
|
228
|
+
The same 100+ tools are also available as a hosted REST API at `https://api.utilix.tech/v1`. This surface requires an API key and is subject to rate limits and pricing tiers.
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
curl -X POST https://api.utilix.tech/v1/hashing/sha256 \
|
|
232
|
+
-H "Authorization: Bearer $UTILIX_API_KEY" \
|
|
233
|
+
-H "Content-Type: application/json" \
|
|
234
|
+
-d '{"input": "hello world"}'
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Ideal for: polyglot teams, environments where installing Python packages is not possible, and browser-based tooling that needs a backend.
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Development
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
# Clone the repository
|
|
245
|
+
git clone https://github.com/utilix-tech/utilix-sdk-python.git
|
|
246
|
+
cd utilix-sdk-python
|
|
247
|
+
|
|
248
|
+
# Install in editable mode with dev dependencies
|
|
249
|
+
pip install -e ".[dev]"
|
|
250
|
+
|
|
251
|
+
# Run the test suite
|
|
252
|
+
pytest
|
|
253
|
+
|
|
254
|
+
# Run with coverage
|
|
255
|
+
pytest --cov=utilix --cov-report=term-missing
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Publishing to PyPI
|
|
261
|
+
|
|
262
|
+
### Build the distribution
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
python -m build
|
|
266
|
+
# Produces dist/utilix_sdk-x.y.z.tar.gz and dist/utilix_sdk-x.y.z-py3-none-any.whl
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Test on TestPyPI first
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
python -m twine upload --repository testpypi dist/*
|
|
273
|
+
# Install from TestPyPI to verify
|
|
274
|
+
pip install --index-url https://test.pypi.org/simple/ utilix-sdk
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Publish to PyPI
|
|
278
|
+
|
|
279
|
+
```bash
|
|
280
|
+
python -m twine upload dist/*
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### GitHub Actions with OIDC trusted publisher (recommended)
|
|
284
|
+
|
|
285
|
+
Store no tokens. Configure a trusted publisher on PyPI (Settings > Publishing > Add a new publisher) and use the official PyPA action:
|
|
286
|
+
|
|
287
|
+
```yaml
|
|
288
|
+
# .github/workflows/publish.yml
|
|
289
|
+
name: Publish to PyPI
|
|
290
|
+
|
|
291
|
+
on:
|
|
292
|
+
push:
|
|
293
|
+
tags:
|
|
294
|
+
- "v*"
|
|
295
|
+
|
|
296
|
+
jobs:
|
|
297
|
+
publish:
|
|
298
|
+
runs-on: ubuntu-latest
|
|
299
|
+
permissions:
|
|
300
|
+
id-token: write # Required for OIDC
|
|
301
|
+
|
|
302
|
+
steps:
|
|
303
|
+
- uses: actions/checkout@v4
|
|
304
|
+
|
|
305
|
+
- uses: actions/setup-python@v5
|
|
306
|
+
with:
|
|
307
|
+
python-version: "3.11"
|
|
308
|
+
|
|
309
|
+
- name: Build
|
|
310
|
+
run: |
|
|
311
|
+
pip install build
|
|
312
|
+
python -m build
|
|
313
|
+
|
|
314
|
+
- name: Publish to PyPI
|
|
315
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
316
|
+
# No api-token needed — OIDC trusted publisher handles auth
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Tag a release (`git tag v0.2.0 && git push --tags`) and the workflow publishes automatically with no stored credentials.
|
|
320
|
+
|
|
321
|
+
---
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
MIT. See [LICENSE](LICENSE) for the full text.
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# utilix-sdk
|
|
2
|
+
|
|
3
|
+
**100+ developer utility tools for Python — runs entirely locally, no API key required.**
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/utilix-sdk/)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](LICENSE)
|
|
8
|
+
[](https://github.com/utilix-tech/utilix-sdk-python/actions)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install utilix-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requires Python 3.11 or later.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Encoding
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from utilix.tools.encoding import encode_base64, decode_base64
|
|
28
|
+
|
|
29
|
+
result = encode_base64("hello world")
|
|
30
|
+
# {"ok": True, "output": "aGVsbG8gd29ybGQ=", "inputBytes": 11, "outputChars": 16}
|
|
31
|
+
|
|
32
|
+
result = decode_base64("aGVsbG8gd29ybGQ=")
|
|
33
|
+
# {"ok": True, "output": "hello world", "outputBytes": 11}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Hashing
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from utilix.tools.hashing import hash_all, hash_one
|
|
40
|
+
|
|
41
|
+
result = hash_all("my-secret")
|
|
42
|
+
# Returns MD5, SHA-1, SHA-256, SHA-384, SHA-512 digests in one call
|
|
43
|
+
|
|
44
|
+
sha256 = hash_one("SHA-256", "my-secret")
|
|
45
|
+
# {"ok": True, "algorithm": "SHA-256", "hex": "...", "bits": 256}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### JSON Tools
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from utilix.tools.json_tools import format_json, minify_json, yaml_to_json
|
|
52
|
+
|
|
53
|
+
pretty = format_json('{"name":"utilix","version":"0.1.0"}', indent=2)
|
|
54
|
+
# {"status": "valid", "output": "{\n \"name\": \"utilix\", ...", ...}
|
|
55
|
+
|
|
56
|
+
minified = minify_json('{\n "a": 1,\n "b": 2\n}')
|
|
57
|
+
# {"ok": True, "output": "{\"a\":1,\"b\":2}", ...}
|
|
58
|
+
|
|
59
|
+
as_json = yaml_to_json("name: utilix\nversion: 0.1.0")
|
|
60
|
+
# {"ok": True, "output": "{\"name\": \"utilix\", \"version\": \"0.1.0\"}"}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Color
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from utilix.tools.color import hex_to_rgb, check_contrast, generate_palette
|
|
67
|
+
|
|
68
|
+
rgb = hex_to_rgb("#3B82F6")
|
|
69
|
+
# {"ok": True, "r": 59, "g": 130, "b": 246}
|
|
70
|
+
|
|
71
|
+
contrast = check_contrast("#FFFFFF", "#3B82F6")
|
|
72
|
+
# {"ratio": 3.94, "aa_normal": False, "aa_large": True, "aaa_normal": False, ...}
|
|
73
|
+
|
|
74
|
+
palette = generate_palette("#3B82F6", scheme="complementary")
|
|
75
|
+
# Returns list of hex colors forming a complementary palette
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Media
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
from utilix.tools.media import compress_image, convert_image
|
|
82
|
+
|
|
83
|
+
with open("photo.jpg", "rb") as f:
|
|
84
|
+
image_bytes = f.read()
|
|
85
|
+
|
|
86
|
+
result = compress_image(image_bytes, quality=75, format="JPEG")
|
|
87
|
+
# {"ok": True, "output": bytes, "original_size": 204800, "compressed_size": 61440, "ratio": 0.3}
|
|
88
|
+
|
|
89
|
+
converted = convert_image(image_bytes, target_format="WEBP")
|
|
90
|
+
# {"ok": True, "output": bytes, "format": "WEBP"}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### CSS
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from utilix.tools.css import generate_gradient, calc_specificity, minify_css
|
|
97
|
+
|
|
98
|
+
gradient = generate_gradient({
|
|
99
|
+
"type": "linear",
|
|
100
|
+
"angle": 135,
|
|
101
|
+
"stops": [{"color": "#667eea", "position": 0}, {"color": "#764ba2", "position": 100}]
|
|
102
|
+
})
|
|
103
|
+
# "linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
|
104
|
+
|
|
105
|
+
specificity = calc_specificity("#nav .item:hover")
|
|
106
|
+
# {"score": (0, 1, 1, 1), "display": "0,1,1,1", "explanation": [...]}
|
|
107
|
+
|
|
108
|
+
minified = minify_css("body {\n margin: 0;\n padding: 0;\n}")
|
|
109
|
+
# {"ok": True, "output": "body{margin:0;padding:0}", "saved_bytes": 14}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Time Tools
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
from utilix.tools.time_tools import from_unix, diff_dates, get_next_runs
|
|
116
|
+
|
|
117
|
+
parsed = from_unix(1735689600)
|
|
118
|
+
# {"ok": True, "iso": "2025-01-01T00:00:00+00:00", "relative": "6 months ago", ...}
|
|
119
|
+
|
|
120
|
+
delta = diff_dates("2024-01-01", "2024-12-31")
|
|
121
|
+
# {"ok": True, "days": 365, "months": 12, "human": "12 months"}
|
|
122
|
+
|
|
123
|
+
schedule = get_next_runs("0 9 * * MON-FRI", count=5)
|
|
124
|
+
# Next 5 weekday 9am runs as ISO strings
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Network
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from utilix.tools.network import ip_to_decimal, cidr_info, is_valid_ipv4
|
|
131
|
+
|
|
132
|
+
decimal = ip_to_decimal("192.168.1.1")
|
|
133
|
+
# {"ok": True, "output": 3232235777}
|
|
134
|
+
|
|
135
|
+
subnet = cidr_info("10.0.0.0/24")
|
|
136
|
+
# {"ok": True, "network": "10.0.0.0", "broadcast": "10.0.0.255",
|
|
137
|
+
# "hosts": 254, "netmask": "255.255.255.0", ...}
|
|
138
|
+
|
|
139
|
+
print(is_valid_ipv4("256.0.0.1")) # False
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Modules
|
|
145
|
+
|
|
146
|
+
| Module | Description |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `encoding` | Base64, Base32, URL encoding/decoding, HTML entity encoding |
|
|
149
|
+
| `hashing` | MD5, SHA-1/256/384/512 digests, bcrypt password hashing, htpasswd |
|
|
150
|
+
| `json_tools` | JSON formatting, minification, diffing, CSV conversion, JSONPath, JSON Schema, YAML-JSON |
|
|
151
|
+
| `color` | Color conversion (hex/RGB/HSL/HSV), palettes, contrast ratios, shades/tints, blending |
|
|
152
|
+
| `css` | Gradients, box shadows, border radius, animations, cubic bezier, clamp, specificity, minifier |
|
|
153
|
+
| `media` | Image compression, format conversion, favicon generation, SVG optimization |
|
|
154
|
+
| `time_tools` | Unix timestamp parsing, cron expression parsing, date diffing, timezone conversion |
|
|
155
|
+
| `network` | IPv4 conversion, CIDR calculator, DNS lookup (DoH), IP geolocation |
|
|
156
|
+
| `api_tools` | cURL builder/parser, cURL-to-code, JWT decode/sign, HTTP status codes, CORS/CSP builders |
|
|
157
|
+
| `code` | Regex tester, SQL formatter, HTML formatter/minifier, GraphQL formatter, semver, URL parser, JS minifier |
|
|
158
|
+
| `data` | YAML, TOML, XML, CSV, INI, and `.env` file parsing, validation, and conversion |
|
|
159
|
+
| `generators` | UUID v4/v7, ULID, password generator, random data, QR code generation |
|
|
160
|
+
| `text` | Word counter, case converter, lorem ipsum, slugifier, string escaping, diff viewer, Markdown/HTML |
|
|
161
|
+
| `misc` | Unicode analysis, ASCII art, Morse code, JSON-to-TypeScript/Go/Python/Zod schema generation |
|
|
162
|
+
| `units` | px/rem/vw conversions, byte formatter, number base conversion, aspect ratio, chmod calculator |
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Surface A vs Surface B
|
|
167
|
+
|
|
168
|
+
### Surface A — this package (`utilix-sdk`)
|
|
169
|
+
|
|
170
|
+
Everything in this package runs **locally in your Python process**. There are no network calls for the core utilities (DNS lookup and IP geolocation are the only exceptions, and both hit public free APIs). No account, no API key, no rate limits.
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
pip install utilix-sdk
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Ideal for: scripts, CI pipelines, offline environments, CLIs, and any situation where you want deterministic, zero-cost utility functions.
|
|
177
|
+
|
|
178
|
+
### Surface B — REST API (`api.utilix.tech/v1`)
|
|
179
|
+
|
|
180
|
+
The same 100+ tools are also available as a hosted REST API at `https://api.utilix.tech/v1`. This surface requires an API key and is subject to rate limits and pricing tiers.
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
curl -X POST https://api.utilix.tech/v1/hashing/sha256 \
|
|
184
|
+
-H "Authorization: Bearer $UTILIX_API_KEY" \
|
|
185
|
+
-H "Content-Type: application/json" \
|
|
186
|
+
-d '{"input": "hello world"}'
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Ideal for: polyglot teams, environments where installing Python packages is not possible, and browser-based tooling that needs a backend.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Development
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Clone the repository
|
|
197
|
+
git clone https://github.com/utilix-tech/utilix-sdk-python.git
|
|
198
|
+
cd utilix-sdk-python
|
|
199
|
+
|
|
200
|
+
# Install in editable mode with dev dependencies
|
|
201
|
+
pip install -e ".[dev]"
|
|
202
|
+
|
|
203
|
+
# Run the test suite
|
|
204
|
+
pytest
|
|
205
|
+
|
|
206
|
+
# Run with coverage
|
|
207
|
+
pytest --cov=utilix --cov-report=term-missing
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Publishing to PyPI
|
|
213
|
+
|
|
214
|
+
### Build the distribution
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
python -m build
|
|
218
|
+
# Produces dist/utilix_sdk-x.y.z.tar.gz and dist/utilix_sdk-x.y.z-py3-none-any.whl
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Test on TestPyPI first
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
python -m twine upload --repository testpypi dist/*
|
|
225
|
+
# Install from TestPyPI to verify
|
|
226
|
+
pip install --index-url https://test.pypi.org/simple/ utilix-sdk
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Publish to PyPI
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
python -m twine upload dist/*
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### GitHub Actions with OIDC trusted publisher (recommended)
|
|
236
|
+
|
|
237
|
+
Store no tokens. Configure a trusted publisher on PyPI (Settings > Publishing > Add a new publisher) and use the official PyPA action:
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
# .github/workflows/publish.yml
|
|
241
|
+
name: Publish to PyPI
|
|
242
|
+
|
|
243
|
+
on:
|
|
244
|
+
push:
|
|
245
|
+
tags:
|
|
246
|
+
- "v*"
|
|
247
|
+
|
|
248
|
+
jobs:
|
|
249
|
+
publish:
|
|
250
|
+
runs-on: ubuntu-latest
|
|
251
|
+
permissions:
|
|
252
|
+
id-token: write # Required for OIDC
|
|
253
|
+
|
|
254
|
+
steps:
|
|
255
|
+
- uses: actions/checkout@v4
|
|
256
|
+
|
|
257
|
+
- uses: actions/setup-python@v5
|
|
258
|
+
with:
|
|
259
|
+
python-version: "3.11"
|
|
260
|
+
|
|
261
|
+
- name: Build
|
|
262
|
+
run: |
|
|
263
|
+
pip install build
|
|
264
|
+
python -m build
|
|
265
|
+
|
|
266
|
+
- name: Publish to PyPI
|
|
267
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
268
|
+
# No api-token needed — OIDC trusted publisher handles auth
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Tag a release (`git tag v0.2.0 && git push --tags`) and the workflow publishes automatically with no stored credentials.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## License
|
|
276
|
+
|
|
277
|
+
MIT. See [LICENSE](LICENSE) for the full text.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.26"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "utilix-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "100+ developer utility tools for Python — JSON, encoding, hashing, color, CSS, images, network and more"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "Utilix", email = "hello@utilix.tech" },
|
|
15
|
+
]
|
|
16
|
+
keywords = [
|
|
17
|
+
"developer-tools", "utilities", "json", "encoding", "hashing",
|
|
18
|
+
"color", "css", "image", "network", "sdk", "devtools",
|
|
19
|
+
]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 3 - Alpha",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Topic :: Software Development :: Libraries",
|
|
27
|
+
"Topic :: Utilities",
|
|
28
|
+
]
|
|
29
|
+
dependencies = [
|
|
30
|
+
"pyyaml>=6.0",
|
|
31
|
+
"bcrypt>=4.0",
|
|
32
|
+
"PyJWT>=2.8",
|
|
33
|
+
"jsonschema>=4.0",
|
|
34
|
+
"jsonpath-ng>=1.6",
|
|
35
|
+
"python-dateutil>=2.9",
|
|
36
|
+
"croniter>=2.0",
|
|
37
|
+
"sqlparse>=0.5",
|
|
38
|
+
"beautifulsoup4>=4.12",
|
|
39
|
+
"qrcode>=7.4",
|
|
40
|
+
"semver>=3.0",
|
|
41
|
+
"markdownify>=0.11",
|
|
42
|
+
"markdown>=3.5",
|
|
43
|
+
"requests>=2.31",
|
|
44
|
+
"Pillow>=10.0",
|
|
45
|
+
"tinycss2>=1.2",
|
|
46
|
+
"lxml>=5.0",
|
|
47
|
+
"scour>=0.38",
|
|
48
|
+
"rjsmin>=1.2",
|
|
49
|
+
"openapi-spec-validator>=0.7",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[project.optional-dependencies]
|
|
53
|
+
dev = [
|
|
54
|
+
"pytest>=8.0",
|
|
55
|
+
"pytest-cov>=5.0",
|
|
56
|
+
"build>=1.0",
|
|
57
|
+
"twine>=5.0",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[project.urls]
|
|
61
|
+
Homepage = "https://utilix.tech"
|
|
62
|
+
Documentation = "https://docs.utilix.tech/sdk/python"
|
|
63
|
+
Repository = "https://github.com/utilix-tech/utilix-sdk-python"
|
|
64
|
+
"Bug Tracker" = "https://github.com/utilix-tech/utilix-sdk-python/issues"
|
|
65
|
+
Changelog = "https://utilix.tech/changelog"
|
|
66
|
+
|
|
67
|
+
[tool.hatch.build.targets.wheel]
|
|
68
|
+
packages = ["src/utilix"]
|
|
69
|
+
|
|
70
|
+
[tool.pytest.ini_options]
|
|
71
|
+
testpaths = ["tests"]
|
|
72
|
+
python_files = ["test_*.py"]
|
|
73
|
+
|
|
74
|
+
[tool.hatch.metadata]
|
|
75
|
+
allow-direct-references = true
|