simplutils 0.1.0__py3-none-any.whl
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.
- simplutils/__init__.py +34 -0
- simplutils/__main__.py +3 -0
- simplutils/cli.py +187 -0
- simplutils/interactive.py +195 -0
- simplutils/logs.py +62 -0
- simplutils/registry.py +161 -0
- simplutils/textio.py +25 -0
- simplutils/tools/__init__.py +5 -0
- simplutils/tools/ai.py +239 -0
- simplutils/tools/convert.py +118 -0
- simplutils/tools/diff.py +74 -0
- simplutils/tools/encoding.py +66 -0
- simplutils/tools/files.py +88 -0
- simplutils/tools/generators.py +75 -0
- simplutils/tools/hashing.py +20 -0
- simplutils/tools/images.py +163 -0
- simplutils/tools/jsontools.py +24 -0
- simplutils/tools/jwt.py +32 -0
- simplutils/tools/mapsearch.py +178 -0
- simplutils/tools/pdfs.py +133 -0
- simplutils/tools/pii.py +211 -0
- simplutils/tools/qr.py +40 -0
- simplutils/tools/regex.py +44 -0
- simplutils/tools/text.py +49 -0
- simplutils/tools/timetools.py +41 -0
- simplutils/ui.py +186 -0
- simplutils-0.1.0.dist-info/METADATA +1081 -0
- simplutils-0.1.0.dist-info/RECORD +31 -0
- simplutils-0.1.0.dist-info/WHEEL +4 -0
- simplutils-0.1.0.dist-info/entry_points.txt +2 -0
- simplutils-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,1081 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: simplutils
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Developer utilities for Base64, hashing, JSON/YAML/CSV, JWT, PDFs, images, QR codes, PII redaction and opt-in AI summaries, JSON extraction and classification via Ollama or OpenAI-compatible APIs. Library, CLI, interactive menu and local web UI.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Santhanakrishnan2004/simpl_utils
|
|
6
|
+
Project-URL: Repository, https://github.com/Santhanakrishnan2004/simpl_utils
|
|
7
|
+
Project-URL: Issues, https://github.com/Santhanakrishnan2004/simpl_utils/issues
|
|
8
|
+
Author: Santhana Krishnan
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,base64,cli,image,json,jwt,llm,pdf,pii,qr,redaction,toolbox,utilities,yaml
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Topic :: Utilities
|
|
19
|
+
Requires-Python: >=3.9
|
|
20
|
+
Provides-Extra: all
|
|
21
|
+
Requires-Dist: nicegui>=3.0; extra == 'all'
|
|
22
|
+
Requires-Dist: pillow>=10; extra == 'all'
|
|
23
|
+
Requires-Dist: pypdf>=4; extra == 'all'
|
|
24
|
+
Requires-Dist: pyyaml>=6; extra == 'all'
|
|
25
|
+
Requires-Dist: segno>=1.6; extra == 'all'
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
29
|
+
Requires-Dist: twine; extra == 'dev'
|
|
30
|
+
Provides-Extra: extras
|
|
31
|
+
Requires-Dist: pyyaml>=6; extra == 'extras'
|
|
32
|
+
Requires-Dist: segno>=1.6; extra == 'extras'
|
|
33
|
+
Provides-Extra: files
|
|
34
|
+
Requires-Dist: pillow>=10; extra == 'files'
|
|
35
|
+
Requires-Dist: pypdf>=4; extra == 'files'
|
|
36
|
+
Provides-Extra: ui
|
|
37
|
+
Requires-Dist: nicegui>=3.0; extra == 'ui'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# simplutils
|
|
41
|
+
|
|
42
|
+
**All-in-one developer utilities in a single package:** Base64, hashing, JSON/YAML/CSV, JWT,
|
|
43
|
+
regex, diff, PDF and image tools, QR codes, and PII redaction.
|
|
44
|
+
Use it as a **Python library**, a **command-line tool**, a **step-by-step menu** (nothing to
|
|
45
|
+
memorize), or a **local web page**.
|
|
46
|
+
|
|
47
|
+
Most utilities run **offline on your own machine**. The AI tools make a request only when you run
|
|
48
|
+
one: they use local Ollama by default, or send the text to the remote endpoint you select.
|
|
49
|
+
|
|
50
|
+
- 53 tools in 16 groups
|
|
51
|
+
- Zero required dependencies (AI uses Python's standard library; image/PDF/YAML/QR/UI features are optional extras)
|
|
52
|
+
- Friendly errors, typo suggestions, and a privacy-respecting log
|
|
53
|
+
|
|
54
|
+
After the first PyPI release, install it with `python -m pip install simplutils`. See
|
|
55
|
+
[PUBLISHING.md](PUBLISHING.md) to publish the source on GitHub and release the package to PyPI.
|
|
56
|
+
|
|
57
|
+
This README includes a quick command example for every current utility. More detailed guides are
|
|
58
|
+
planned for [simplutils.santhanakrishnan.dev](https://simplutils.santhanakrishnan.dev) (coming soon).
|
|
59
|
+
AI/LLM tools include summarization, JSON extraction, and classification. Each has examples and
|
|
60
|
+
provider/privacy notes below; the planned docs site will add more detailed guides.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Contents
|
|
65
|
+
|
|
66
|
+
1. [Install](#1-install)
|
|
67
|
+
2. [Quick start](#2-quick-start)
|
|
68
|
+
3. [The interactive menu](#3-the-interactive-menu-nothing-to-memorize)
|
|
69
|
+
4. [Command-line guide](#4-command-line-guide)
|
|
70
|
+
5. [Tool reference with examples](#5-tool-reference-with-examples)
|
|
71
|
+
6. [Recipes (real-world workflows)](#6-recipes-real-world-workflows)
|
|
72
|
+
7. [Using it as a Python library](#7-using-it-as-a-python-library)
|
|
73
|
+
8. [The web UI](#8-the-web-ui)
|
|
74
|
+
9. [Logging and privacy](#9-logging-and-privacy)
|
|
75
|
+
10. [PII redaction: what it does and doesn't do](#10-pii-redaction-what-it-does-and-doesnt-do)
|
|
76
|
+
11. [Troubleshooting and FAQ](#11-troubleshooting-and-faq)
|
|
77
|
+
12. [Extending: add your own tool](#12-extending-add-your-own-tool)
|
|
78
|
+
13. [Development and releasing](#13-development-and-releasing)
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 1. Install
|
|
83
|
+
|
|
84
|
+
Requires **Python 3.9 or newer** (developed and tested on Python 3.13).
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
python -m pip install simplutils # core: text tools, no other dependencies
|
|
88
|
+
python -m pip install "simplutils[all]" # everything: images, PDFs, YAML, QR codes, web UI
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Pick only what you need:
|
|
92
|
+
|
|
93
|
+
| Command | Adds | Needed for |
|
|
94
|
+
|---|---|---|
|
|
95
|
+
| `pip install simplutils` | nothing extra | encoding, hashing, JSON, JWT, regex, diff, CSV, time, PII, generators, and AI tools (with a configured provider) |
|
|
96
|
+
| `pip install "simplutils[files]"` | Pillow, pypdf | image tools and PDF tools |
|
|
97
|
+
| `pip install "simplutils[extras]"` | PyYAML, segno | JSON ↔ YAML and QR codes |
|
|
98
|
+
| `pip install "simplutils[ui]"` | NiceGUI | the local web page (`simplutils ui`) |
|
|
99
|
+
| `pip install "simplutils[all]"` | all of the above | everything |
|
|
100
|
+
|
|
101
|
+
If you run a tool whose extra isn't installed, it tells you exactly what to do, for example:
|
|
102
|
+
`error: this tool needs Pillow: pip install simplutils[files]`.
|
|
103
|
+
|
|
104
|
+
**Tip for command-line use:** `pipx install "simplutils[all]"` installs it in its own isolated
|
|
105
|
+
environment and puts `simplutils` on your PATH.
|
|
106
|
+
|
|
107
|
+
**Install from a wheel or source folder** (before or without publishing to PyPI):
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
pip install simplutils-0.1.0-py3-none-any.whl # a built wheel file
|
|
111
|
+
pip install "simplutils-0.1.0-py3-none-any.whl[all]" # ... with extras
|
|
112
|
+
pip install -e ".[all,dev]" # editable install from the project folder
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Check it worked:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
simplutils --version
|
|
119
|
+
simplutils list
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
If `simplutils` isn't found (common on Windows), use `python -m simplutils ...` instead. See
|
|
123
|
+
[Troubleshooting](#11-troubleshooting-and-faq).
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 2. Quick start
|
|
128
|
+
|
|
129
|
+
There are four ways to use the same tools. Pick whichever you like.
|
|
130
|
+
|
|
131
|
+
**1. The menu: just type `simplutils`.** No flags to remember.
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
$ simplutils
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**2. Direct commands: fast and scriptable.**
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
simplutils b64-encode "hello world" # aGVsbG8gd29ybGQ=
|
|
141
|
+
simplutils hash "hello" --algo md5 # 5d41402abc4b2a76b9719d911017c592
|
|
142
|
+
echo "a@b.com" | simplutils pii-redact # [EMAIL]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**3. Python code.**
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
import simplutils as eu
|
|
149
|
+
eu.b64_encode("hello world") # 'aGVsbG8gd29ybGQ='
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
**4. A web page on your own machine.**
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
simplutils ui # opens http://localhost:8080
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 3. The interactive menu (nothing to memorize)
|
|
161
|
+
|
|
162
|
+
Run `simplutils` with no arguments (or `simplutils menu`). You get a numbered list of every tool.
|
|
163
|
+
|
|
164
|
+
- Type a **number** to pick a tool, or a **word to search** (`pdf`, `base64`, `qr`).
|
|
165
|
+
- It asks for the input, then for each option, showing the default. **Press Enter to accept it.**
|
|
166
|
+
- For files: **drag the file into the window** to paste its path (quotes are handled for you).
|
|
167
|
+
- For text: type `@path\to\file.txt` to load it from a file, or `<<` to paste several lines
|
|
168
|
+
(finish with an empty line).
|
|
169
|
+
- At the end it offers to **save the result** to a file. Files such as a merged PDF are saved
|
|
170
|
+
with a sensible default name.
|
|
171
|
+
- `?` shows the list again, `q` quits. A mistake gives a friendly message, then back to the menu.
|
|
172
|
+
|
|
173
|
+
A real session (hashing a word):
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
Tool> hash
|
|
177
|
+
|
|
178
|
+
== Hash ==
|
|
179
|
+
Compute a hash digest of the text.
|
|
180
|
+
|
|
181
|
+
Enter the text. Type @path to load it from a file, or << for multi-line input.
|
|
182
|
+
Text> hello
|
|
183
|
+
|
|
184
|
+
Options (just press Enter to accept the default):
|
|
185
|
+
algo [sha256, sha512, sha1, md5] (Enter = sha256): md5
|
|
186
|
+
|
|
187
|
+
5d41402abc4b2a76b9719d911017c592
|
|
188
|
+
|
|
189
|
+
Save the result to a file? Type a path, or Enter to skip:
|
|
190
|
+
Press Enter to go back to the menu...
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 4. Command-line guide
|
|
196
|
+
|
|
197
|
+
### The general shape
|
|
198
|
+
|
|
199
|
+
```text
|
|
200
|
+
simplutils <tool> [input] [--options] [-o output-file]
|
|
201
|
+
simplutils list [word] show tools, optionally filtered ("simplutils list pdf")
|
|
202
|
+
simplutils <tool> -h show the options of one tool
|
|
203
|
+
simplutils menu the interactive menu
|
|
204
|
+
simplutils ui the web UI
|
|
205
|
+
simplutils logs recent log lines
|
|
206
|
+
simplutils -v <tool> ... also print log messages on screen (-v goes BEFORE the tool name)
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Giving input
|
|
210
|
+
|
|
211
|
+
| Tool takes | You provide | Example |
|
|
212
|
+
|---|---|---|
|
|
213
|
+
| **text** | an argument, `-f file`, or piped stdin | `simplutils hash "hello"` · `simplutils hash -f notes.txt` · `type notes.txt \| simplutils hash` |
|
|
214
|
+
| **one file** | its path (`-` reads binary stdin) | `simplutils image-info photo.png` |
|
|
215
|
+
| **several files** | their paths, in order | `simplutils pdf-merge a.pdf b.pdf c.pdf -o all.pdf` |
|
|
216
|
+
| **nothing** | nothing | `simplutils uuid --count 3` |
|
|
217
|
+
|
|
218
|
+
Text files may be UTF-8 (with or without a BOM) or UTF-16. This covers files saved by Windows
|
|
219
|
+
Notepad and PowerShell.
|
|
220
|
+
|
|
221
|
+
### Getting output
|
|
222
|
+
|
|
223
|
+
- By default the result is **printed**.
|
|
224
|
+
- `-o file` **saves** it instead. For tools that make files (a PDF, an image, a ZIP), `-o` sets the
|
|
225
|
+
file name; without it the tool uses a default such as `merged.pdf` in the current folder.
|
|
226
|
+
|
|
227
|
+
### Options
|
|
228
|
+
|
|
229
|
+
- Option names match the tool's parameters with dashes: `--no-symbols`, `--infer-types`.
|
|
230
|
+
- Yes/no options are plain flags: `--urlsafe`, `--ignore-case`.
|
|
231
|
+
- Choice options list their values in `-h`: `--algo sha256|sha512|sha1|md5`.
|
|
232
|
+
- Mistype a command or a choice and it suggests the right one:
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
$ simplutils b64encode hi
|
|
236
|
+
simplutils: error: unknown choice 'b64encode'. Did you mean: b64-encode, b64-decode, url-encode? See all tools with: simplutils list
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Exit codes (for scripts and CI)
|
|
240
|
+
|
|
241
|
+
| Code | Meaning |
|
|
242
|
+
|---|---|
|
|
243
|
+
| `0` | success |
|
|
244
|
+
| `1` | the tool reported a problem (bad input, missing file, wrong file type) |
|
|
245
|
+
| `2` | command-line usage error (unknown option or command) |
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## 5. Tool reference with examples
|
|
250
|
+
|
|
251
|
+
Examples for the existing tools were run for real; quick-reference commands use sample filenames
|
|
252
|
+
that you can replace with your own. AI examples require a configured provider. Every tool can also be called from Python
|
|
253
|
+
([section 7](#7-using-it-as-a-python-library)).
|
|
254
|
+
|
|
255
|
+
### Quick example for every command
|
|
256
|
+
|
|
257
|
+
These are short starting points for all 53 commands. Replace sample filenames with your own.
|
|
258
|
+
Some commands need optional extras; the relevant sections below identify them.
|
|
259
|
+
|
|
260
|
+
| Utility | Example |
|
|
261
|
+
|---|---|
|
|
262
|
+
| `json-to-yaml` | `simplutils json-to-yaml -f config.json` |
|
|
263
|
+
| `yaml-to-json` | `simplutils yaml-to-json -f config.yaml` |
|
|
264
|
+
| `json-to-csv` | `simplutils json-to-csv -f users.json -o users.csv` |
|
|
265
|
+
| `csv-to-json` | `simplutils csv-to-json -f people.csv --infer-types` |
|
|
266
|
+
| `diff` | `simplutils diff before.txt after.txt` |
|
|
267
|
+
| `json-diff` | `simplutils json-diff before.json after.json` |
|
|
268
|
+
| `b64-encode` | `simplutils b64-encode "hello"` |
|
|
269
|
+
| `b64-decode` | `simplutils b64-decode "aGVsbG8="` |
|
|
270
|
+
| `url-encode` | `simplutils url-encode "hello world"` |
|
|
271
|
+
| `url-decode` | `simplutils url-decode "hello%20world"` |
|
|
272
|
+
| `hex-encode` | `simplutils hex-encode "hello"` |
|
|
273
|
+
| `hex-decode` | `simplutils hex-decode 68656c6c6f` |
|
|
274
|
+
| `html-escape` | `simplutils html-escape "<p>Tom & Jerry</p>"` |
|
|
275
|
+
| `html-unescape` | `simplutils html-unescape "<p>Hello</p>"` |
|
|
276
|
+
| `pdf-to-b64` | `simplutils pdf-to-b64 report.pdf -o report.txt` |
|
|
277
|
+
| `b64-to-pdf` | `simplutils b64-to-pdf -f report.txt -o copy.pdf` |
|
|
278
|
+
| `image-to-b64` | `simplutils image-to-b64 logo.png --data-uri` |
|
|
279
|
+
| `b64-to-image` | `simplutils b64-to-image -f logo.txt -o copy.png` |
|
|
280
|
+
| `uuid` | `simplutils uuid --count 3` |
|
|
281
|
+
| `random-text` | `simplutils random-text --length 16 --charset hex` |
|
|
282
|
+
| `password` | `simplutils password --length 20 --no-symbols` |
|
|
283
|
+
| `hash` | `simplutils hash "hello" --algo sha256` |
|
|
284
|
+
| `hmac` | `simplutils hmac "message" --key "your-key"` |
|
|
285
|
+
| `image-convert` | `simplutils image-convert photo.png --to webp -o photo.webp` |
|
|
286
|
+
| `image-resize` | `simplutils image-resize photo.png --width 800 -o small.png` |
|
|
287
|
+
| `image-compress` | `simplutils image-compress photo.jpg --quality 60 -o small.jpg` |
|
|
288
|
+
| `image-info` | `simplutils image-info photo.png` |
|
|
289
|
+
| `image-to-pdf` | `simplutils image-to-pdf page1.jpg page2.jpg -o pages.pdf` |
|
|
290
|
+
| `json-format` | `simplutils json-format -f config.json` |
|
|
291
|
+
| `json-minify` | `simplutils json-minify -f config.json` |
|
|
292
|
+
| `jwt-decode` | `simplutils jwt-decode "<header>.<payload>.<signature>"` |
|
|
293
|
+
| `map-search` | `simplutils map-search -f users.json --query email` |
|
|
294
|
+
| `pdf-merge` | `simplutils pdf-merge cover.pdf report.pdf -o combined.pdf` |
|
|
295
|
+
| `pdf-extract` | `simplutils pdf-extract report.pdf --pages 1-3 -o excerpt.pdf` |
|
|
296
|
+
| `pdf-split` | `simplutils pdf-split report.pdf -o pages.zip` |
|
|
297
|
+
| `pdf-text` | `simplutils pdf-text report.pdf` |
|
|
298
|
+
| `pdf-info` | `simplutils pdf-info report.pdf` |
|
|
299
|
+
| `pii-redact` | `simplutils pii-redact -f server.log -o clean.log` |
|
|
300
|
+
| `pii-scan` | `simplutils pii-scan -f server.log` |
|
|
301
|
+
| `pii-types` | `simplutils pii-types` |
|
|
302
|
+
| `qr-generate` | `simplutils qr-generate "https://example.com" -o qr.png` |
|
|
303
|
+
| `qr-text` | `simplutils qr-text "https://example.com"` |
|
|
304
|
+
| `regex-test` | `simplutils regex-test "order 123" --pattern "\d+"` |
|
|
305
|
+
| `regex-replace` | `simplutils regex-replace "order 123" --pattern "\d+" --replacement "NUMBER"` |
|
|
306
|
+
| `case-convert` | `simplutils case-convert "hello world" --style snake` |
|
|
307
|
+
| `slugify` | `simplutils slugify "Hello, World!"` |
|
|
308
|
+
| `count` | `simplutils count "one two three"` |
|
|
309
|
+
| `ts-to-date` | `simplutils ts-to-date 1700000000` |
|
|
310
|
+
| `date-to-ts` | `simplutils date-to-ts "2026-01-31 14:30"` |
|
|
311
|
+
| `now` | `simplutils now` |
|
|
312
|
+
| `ai-summarize` | `simplutils ai-summarize -f article.txt --style bullets` |
|
|
313
|
+
| `ai-extract-json` | `simplutils ai-extract-json -f invoice.txt --fields vendor,total,date` |
|
|
314
|
+
| `ai-classify` | `simplutils ai-classify -f feedback.txt --labels positive,neutral,negative` |
|
|
315
|
+
|
|
316
|
+
### Encoding (8 tools)
|
|
317
|
+
|
|
318
|
+
| Tool | What it does |
|
|
319
|
+
|---|---|
|
|
320
|
+
| `b64-encode` / `b64-decode` | Base64. Options: `--urlsafe`. Decode accepts missing `=` padding. |
|
|
321
|
+
| `url-encode` / `url-decode` | Percent-encoding. Option: `--plus` (spaces as `+`). |
|
|
322
|
+
| `hex-encode` / `hex-decode` | Text ↔ hexadecimal. |
|
|
323
|
+
| `html-escape` / `html-unescape` | `&`, `<`, `>` and quotes ↔ HTML entities. |
|
|
324
|
+
|
|
325
|
+
```text
|
|
326
|
+
$ simplutils b64-encode "hello world"
|
|
327
|
+
aGVsbG8gd29ybGQ=
|
|
328
|
+
$ simplutils b64-decode "aGVsbG8gd29ybGQ="
|
|
329
|
+
hello world
|
|
330
|
+
$ simplutils url-decode "name%3DAsha%20%26%20co"
|
|
331
|
+
name=Asha & co
|
|
332
|
+
$ simplutils hex-encode "hi"
|
|
333
|
+
6869
|
|
334
|
+
$ simplutils html-escape '<a href="x">Tom & Jerry</a>'
|
|
335
|
+
<a href="x">Tom & Jerry</a>
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Files ↔ Base64 (4 tools)
|
|
339
|
+
|
|
340
|
+
Turn a PDF or image into Base64 text (for JSON payloads, HTML, emails) and back.
|
|
341
|
+
|
|
342
|
+
| Tool | What it does |
|
|
343
|
+
|---|---|
|
|
344
|
+
| `pdf-to-b64` | PDF file → Base64. `--data-uri` gives `data:application/pdf;base64,...` |
|
|
345
|
+
| `b64-to-pdf` | Base64 (or a data URI) → PDF file |
|
|
346
|
+
| `image-to-b64` | PNG/JPG/GIF/WebP/BMP/ICO/SVG → Base64. `--data-uri` adds the right `data:image/...` prefix |
|
|
347
|
+
| `b64-to-image` | Base64 (or data URI) → image file; the format is detected automatically |
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
simplutils pdf-to-b64 report.pdf -o report.txt # long Base64, so save it to a file
|
|
351
|
+
simplutils b64-to-pdf -f report.txt -o copy.pdf # and back
|
|
352
|
+
simplutils image-to-b64 logo.png --data-uri # prints data:image/png;base64,iVBOR...
|
|
353
|
+
simplutils b64-to-image -f logo.txt -o logo.png
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
The tools check the content: giving a PNG to `pdf-to-b64` fails with a clear message instead of
|
|
357
|
+
producing nonsense. Large Base64 is too long for a command line, so use `-o` / `-f`.
|
|
358
|
+
|
|
359
|
+
### Images (5 tools): needs `simplutils[files]`
|
|
360
|
+
|
|
361
|
+
| Tool | What it does |
|
|
362
|
+
|---|---|
|
|
363
|
+
| `image-info` | Format, size in pixels, colour mode, file size |
|
|
364
|
+
| `image-resize` | `--width`, `--height`, or `--scale` (percent). Aspect ratio is kept; width+height fits inside the box, `--exact` forces the size. Max 20000 px per side |
|
|
365
|
+
| `image-convert` | `--to png\|jpg\|webp\|bmp\|gif`, `--quality 1-100`. Transparency becomes white for JPG |
|
|
366
|
+
| `image-compress` | `--quality` (JPG/WebP), PNG is optimised losslessly, optional `--max-width`. Never returns a bigger file |
|
|
367
|
+
| `image-to-pdf` | One or more images → one PDF, one image per page, in the order given |
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
simplutils image-info photo.png
|
|
371
|
+
simplutils image-resize photo.png --width 800 -o small.png # height follows automatically
|
|
372
|
+
simplutils image-resize photo.png --scale 50 -o half.png # 50 %
|
|
373
|
+
simplutils image-convert photo.png --to webp --quality 80 -o photo.webp
|
|
374
|
+
simplutils image-compress photo.jpg --quality 60 --max-width 1600 -o photo_small.jpg
|
|
375
|
+
simplutils image-to-pdf page1.png page2.png -o album.pdf
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
```text
|
|
379
|
+
$ simplutils image-info small.png
|
|
380
|
+
format: PNG
|
|
381
|
+
size: 150 x 100 px
|
|
382
|
+
mode: RGB
|
|
383
|
+
file size: 230 bytes
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Animated GIF/WebP files keep only their first frame when converted or resized. Photos are
|
|
387
|
+
rotated according to their EXIF orientation.
|
|
388
|
+
|
|
389
|
+
### PDF (5 tools): needs `simplutils[files]`
|
|
390
|
+
|
|
391
|
+
| Tool | What it does |
|
|
392
|
+
|---|---|
|
|
393
|
+
| `pdf-info` | Page count, page size, file size, encryption, title/author |
|
|
394
|
+
| `pdf-merge` | Join two or more PDFs, in the order given |
|
|
395
|
+
| `pdf-extract` | Keep only some pages: `--pages 1-3,5,8-` (1-based; `8-` means "from 8 to the end"; order and repeats are respected) |
|
|
396
|
+
| `pdf-split` | One PDF per page, delivered as a ZIP (`page_01.pdf`, `page_02.pdf`, ...) |
|
|
397
|
+
| `pdf-text` | Extract text, optionally `--pages 1-3`. Scanned PDFs have no text to extract and are reported as such |
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
simplutils pdf-info contract.pdf
|
|
401
|
+
simplutils pdf-merge cover.pdf body.pdf appendix.pdf -o full.pdf
|
|
402
|
+
simplutils pdf-extract book.pdf --pages 1-3,10 -o excerpt.pdf
|
|
403
|
+
simplutils pdf-split book.pdf -o pages.zip
|
|
404
|
+
simplutils pdf-text paper.pdf --pages 1-2
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
```text
|
|
408
|
+
$ simplutils pdf-info five_pages.pdf
|
|
409
|
+
pages: 5
|
|
410
|
+
page size: 200 x 300 pt
|
|
411
|
+
file size: 911 bytes
|
|
412
|
+
encrypted: no
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Password-protected PDFs are not supported yet (you get a clear "password-protected" message).
|
|
416
|
+
|
|
417
|
+
### Privacy / PII (3 tools)
|
|
418
|
+
|
|
419
|
+
See [section 10](#10-pii-redaction-what-it-does-and-doesnt-do) for details and limits.
|
|
420
|
+
|
|
421
|
+
| Tool | What it does |
|
|
422
|
+
|---|---|
|
|
423
|
+
| `pii-scan` | Report what sensitive data the text contains and where, **without printing the values** |
|
|
424
|
+
| `pii-redact` | Replace it with placeholders. `--mode label\|mask\|hash`, `--only email,phone`, `--exclude phone` |
|
|
425
|
+
| `pii-types` | List every type that can be detected |
|
|
426
|
+
|
|
427
|
+
```text
|
|
428
|
+
$ simplutils pii-scan -f server.log
|
|
429
|
+
Found 9 potential item(s) of 9 type(s)
|
|
430
|
+
|
|
431
|
+
Summary
|
|
432
|
+
email 1
|
|
433
|
+
ip-address 1
|
|
434
|
+
phone 1
|
|
435
|
+
pan 1
|
|
436
|
+
credit-card 1
|
|
437
|
+
bearer-token 1
|
|
438
|
+
url-password 1
|
|
439
|
+
aws-key 1
|
|
440
|
+
password 1
|
|
441
|
+
|
|
442
|
+
Details (values are hidden)
|
|
443
|
+
line 1 email pr***
|
|
444
|
+
line 2 phone +9***
|
|
445
|
+
line 3 credit-card 41***
|
|
446
|
+
...
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
```text
|
|
450
|
+
$ echo "Contact priya@corp.in or +91 98765 43210, key AKIAIOSFODNN7EXAMPLE" | simplutils pii-redact
|
|
451
|
+
Contact [EMAIL] or [PHONE], key [AWS-KEY]
|
|
452
|
+
|
|
453
|
+
$ echo "... same text ..." | simplutils pii-redact --mode hash
|
|
454
|
+
Contact [EMAIL#201c7155] or [PHONE#407d0cf8], key [AWS-KEY#702f2990] (tokens differ on every run)
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
### Convert (4 tools)
|
|
458
|
+
|
|
459
|
+
| Tool | What it does |
|
|
460
|
+
|---|---|
|
|
461
|
+
| `json-to-yaml` / `yaml-to-json` | JSON ↔ YAML (needs `simplutils[extras]`). Key order is kept. A YAML file with several `---` documents becomes a JSON list |
|
|
462
|
+
| `json-to-csv` | JSON array of objects → CSV. Nested objects become dotted columns (`user.name`); lists stay as JSON text |
|
|
463
|
+
| `csv-to-json` | CSV (first row = headers) → JSON. `--delimiter auto\|comma\|semicolon\|tab\|pipe`; `--infer-types` turns `31` into a number, `true` into a boolean, empty cells into `null` |
|
|
464
|
+
|
|
465
|
+
```text
|
|
466
|
+
$ simplutils yaml-to-json "name: demo
|
|
467
|
+
tags: [a, b]"
|
|
468
|
+
{
|
|
469
|
+
"name": "demo",
|
|
470
|
+
"tags": [
|
|
471
|
+
"a",
|
|
472
|
+
"b"
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
$ simplutils csv-to-json -f people.csv --infer-types
|
|
477
|
+
[
|
|
478
|
+
{
|
|
479
|
+
"name": "Asha",
|
|
480
|
+
"age": 31,
|
|
481
|
+
"city": "Chennai",
|
|
482
|
+
"active": true
|
|
483
|
+
},
|
|
484
|
+
... (one object per row; output shortened here)
|
|
485
|
+
]
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
### Compare (2 tools)
|
|
489
|
+
|
|
490
|
+
Both take **two files: first the "before", then the "after"**.
|
|
491
|
+
|
|
492
|
+
```text
|
|
493
|
+
$ simplutils json-diff config_v1.json config_v2.json
|
|
494
|
+
~ database.host: "db1.internal" -> "db2.internal"
|
|
495
|
+
+ features[2]: "reports"
|
|
496
|
+
- legacy_mode: true
|
|
497
|
+
~ replicas: 2 -> 4
|
|
498
|
+
+ timeout_seconds: 30
|
|
499
|
+
~ version: "1.4.0" -> "1.5.0"
|
|
500
|
+
|
|
501
|
+
$ simplutils diff notes_v1.txt notes_v2.txt
|
|
502
|
+
--- before
|
|
503
|
+
+++ after
|
|
504
|
+
@@ -1,4 +1,5 @@
|
|
505
|
+
Meeting notes
|
|
506
|
+
- Review the billing release
|
|
507
|
+
-- Fix the refund bug
|
|
508
|
+
+- Fix the refund bug (done)
|
|
509
|
+
- Plan the Q4 roadmap
|
|
510
|
+
+- Book the retro
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
`+` added, `-` removed, `~` changed. `diff` options: `--context N` (lines of context, default 3),
|
|
514
|
+
`--ignore-whitespace`.
|
|
515
|
+
|
|
516
|
+
### QR codes (2 tools): needs `simplutils[extras]`
|
|
517
|
+
|
|
518
|
+
```bash
|
|
519
|
+
simplutils qr-generate "https://example.com" -o qr.png # PNG image
|
|
520
|
+
simplutils qr-generate "https://example.com" --kind svg -o qr.svg # SVG
|
|
521
|
+
simplutils qr-text "https://example.com" # scannable right in the terminal
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Options: `--scale 1-50` (pixel size of each square), `--error L|M|Q|H` (error correction: higher
|
|
525
|
+
means more damage tolerance but a denser code). Generating only; reading QR codes is not supported.
|
|
526
|
+
|
|
527
|
+
### Text and JSON (7 tools)
|
|
528
|
+
|
|
529
|
+
| Tool | What it does |
|
|
530
|
+
|---|---|
|
|
531
|
+
| `json-format` | Validate and pretty-print. `--indent 2`, `--sort-keys` |
|
|
532
|
+
| `json-minify` | Validate and compact onto one line |
|
|
533
|
+
| `regex-test` | List every match with position and capture groups. `--pattern` required; `--ignore-case`, `--multiline`, `--dotall` |
|
|
534
|
+
| `regex-replace` | Replace matches; use `\1` or `\g<name>` in `--replacement` |
|
|
535
|
+
| `case-convert` | `--style snake\|camel\|pascal\|kebab\|constant\|title\|upper\|lower` |
|
|
536
|
+
| `slugify` | URL-friendly slug (accents removed) |
|
|
537
|
+
| `count` | Characters, words, lines |
|
|
538
|
+
|
|
539
|
+
```text
|
|
540
|
+
$ simplutils json-format '{"b":1,"a":[1,2]}' --sort-keys # (PowerShell: see the FAQ on quoting)
|
|
541
|
+
{
|
|
542
|
+
"a": [
|
|
543
|
+
1,
|
|
544
|
+
2
|
|
545
|
+
],
|
|
546
|
+
"b": 1
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
$ simplutils regex-test "order 123, order 4567" --pattern "order (\d+)"
|
|
550
|
+
2 matches
|
|
551
|
+
#1 [0:9] 'order 123'
|
|
552
|
+
group 1: '123'
|
|
553
|
+
#2 [11:21] 'order 4567'
|
|
554
|
+
group 1: '4567'
|
|
555
|
+
|
|
556
|
+
$ simplutils regex-replace "john smith" --pattern "(\w+) (\w+)" --replacement '\2, \1'
|
|
557
|
+
smith, john
|
|
558
|
+
|
|
559
|
+
$ simplutils case-convert "HTTPServerError" --style snake
|
|
560
|
+
http_server_error
|
|
561
|
+
|
|
562
|
+
$ simplutils slugify "Héllo, World! 2026"
|
|
563
|
+
hello-world-2026
|
|
564
|
+
|
|
565
|
+
$ simplutils count "one two three
|
|
566
|
+
four five"
|
|
567
|
+
characters: 23
|
|
568
|
+
words: 5
|
|
569
|
+
lines: 2
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
> Regex patterns are run as given. A badly written pattern on very large input can be slow,
|
|
573
|
+
> because Python's `re` has no timeout.
|
|
574
|
+
|
|
575
|
+
### Hashing and security (3 tools)
|
|
576
|
+
|
|
577
|
+
```text
|
|
578
|
+
$ simplutils hash "hello" --algo sha256
|
|
579
|
+
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
|
|
580
|
+
$ simplutils hmac "message" --key secret
|
|
581
|
+
8b5f48702995c1598c573db1e21866a9b825d4a794d169d7060a03605796360b
|
|
582
|
+
$ simplutils jwt-decode "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMiLCJleHAiOjF9.sig"
|
|
583
|
+
{
|
|
584
|
+
"header": {
|
|
585
|
+
"alg": "HS256"
|
|
586
|
+
},
|
|
587
|
+
"payload": {
|
|
588
|
+
"sub": "123",
|
|
589
|
+
"exp": 1
|
|
590
|
+
},
|
|
591
|
+
"times": {
|
|
592
|
+
"exp": "1970-01-01T00:00:01+00:00"
|
|
593
|
+
},
|
|
594
|
+
"expired": true
|
|
595
|
+
}
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
`hash --algo` accepts `sha256` (default), `sha512`, `sha1`, `md5`. `jwt-decode` shows the header and
|
|
599
|
+
payload and whether the token has expired; **it does not verify the signature**.
|
|
600
|
+
|
|
601
|
+
### Time (3 tools)
|
|
602
|
+
|
|
603
|
+
```text
|
|
604
|
+
$ simplutils ts-to-date 1700000000 # seconds or milliseconds, detected automatically
|
|
605
|
+
UTC: 2023-11-14T22:13:20+00:00
|
|
606
|
+
Local: 2023-11-15T03:43:20+05:30 # (your own time zone)
|
|
607
|
+
$ simplutils date-to-ts "2026-01-31 14:30" # no zone given = UTC
|
|
608
|
+
seconds: 1769869800
|
|
609
|
+
milliseconds: 1769869800000
|
|
610
|
+
$ simplutils now
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### Generators (3 tools)
|
|
614
|
+
|
|
615
|
+
```bash
|
|
616
|
+
simplutils uuid --count 5 # random UUIDs (v4)
|
|
617
|
+
simplutils password --length 20 # cryptographically secure; --no-symbols for letters+digits
|
|
618
|
+
simplutils random-text --length 40 # random text of exactly 40 characters
|
|
619
|
+
simplutils random-text --length 12 --charset hex --count 3 # three 12-character hex strings
|
|
620
|
+
simplutils random-text --length 60 --charset words # lorem-style words, cut to exactly 60 characters
|
|
621
|
+
simplutils random-text --length 10 --custom ACGT # only the characters you give
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
`--charset` is one of `alnum` (default), `letters`, `lower`, `upper`, `digits`, `hex`, `words`.
|
|
625
|
+
`--custom` overrides it. Length is 1-1,000,000, count 1-1000. Uses the operating system's random source.
|
|
626
|
+
Use `password` for secrets; `random-text` is for test data, IDs and filler.
|
|
627
|
+
|
|
628
|
+
### Data: search a map without writing a snippet (1 tool)
|
|
629
|
+
|
|
630
|
+
`map-search` finds, counts and reads values in a JSON object/list (or YAML, with `simplutils[extras]`),
|
|
631
|
+
at any nesting depth, in one pass. Sample `users.json`:
|
|
632
|
+
|
|
633
|
+
```json
|
|
634
|
+
{"users": [{"name": "Asha", "city": "Chennai", "age": 31},
|
|
635
|
+
{"name": "Ravi", "city": "Pune", "age": 28},
|
|
636
|
+
{"name": "Meena", "city": "Chennai", "age": 31}],
|
|
637
|
+
"meta": {"city": "Chennai"}}
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
| You want | Command |
|
|
641
|
+
|---|---|
|
|
642
|
+
| Every key called `city`, with its path | `simplutils map-search -f users.json --query city` |
|
|
643
|
+
| How many values equal `Chennai` | `simplutils map-search -f users.json --action count --by value --query Chennai` |
|
|
644
|
+
| Where the value `Ravi` is | `simplutils map-search -f users.json --by value --query Ravi` |
|
|
645
|
+
| Values containing `a` | `... --by value --query a --match contains` |
|
|
646
|
+
| Regex, ignoring case | `... --by value --query "^c" --match regex --ignore-case` |
|
|
647
|
+
| How often each city appears | `simplutils map-search -f users.json --action tally --query city` |
|
|
648
|
+
| One value by path | `simplutils map-search -f users.json --action get --query "users[0].name"` |
|
|
649
|
+
| All names | `simplutils map-search -f users.json --action get --query "users[*].name"` |
|
|
650
|
+
|
|
651
|
+
```
|
|
652
|
+
$ simplutils map-search -f users.json --query city
|
|
653
|
+
4 matching keys
|
|
654
|
+
users[0].city: "Chennai"
|
|
655
|
+
users[1].city: "Pune"
|
|
656
|
+
users[2].city: "Chennai"
|
|
657
|
+
meta.city: "Chennai"
|
|
658
|
+
|
|
659
|
+
$ simplutils map-search -f users.json --action tally --query city
|
|
660
|
+
4 match(es) across 2 distinct value(s)
|
|
661
|
+
"Chennai" 3
|
|
662
|
+
"Pune" 1
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
- `--action`: `find` (default, lists paths), `count` (just the number), `get` (read a path), `tally` (count each distinct value of a key).
|
|
666
|
+
- `--by`: `key` (default) or `value`. `--match`: `exact` (default), `contains`, `regex`. `--limit`: lines shown for find/tally (default 100).
|
|
667
|
+
- Paths use `a.b`, `list[0]`, `list[-1]` (last), `list[*]` (all) and `["key.with.dots"]`. The paths that `find` prints work in `get`.
|
|
668
|
+
- Numbers and booleans match as text (`31`, `true`). The input must be an object or list.
|
|
669
|
+
- As a library, pass your Python dict or list straight in (or JSON text):
|
|
670
|
+
```python
|
|
671
|
+
from simplutils import map_search
|
|
672
|
+
users = {"users": [{"name": "Asha", "city": "Chennai"}, {"name": "Ravi", "city": "Pune"}]}
|
|
673
|
+
map_search(users, query="city") # keys named city, with paths
|
|
674
|
+
map_search(users, action="count", by="value", query="Chennai") # -> "1"
|
|
675
|
+
map_search(users, action="tally", query="city") # count of each distinct city
|
|
676
|
+
map_search(users, action="get", query="users[*].name") # JSON text of ["Asha", "Ravi"]
|
|
677
|
+
```
|
|
678
|
+
The result is always a string; for `get`, use `json.loads(...)` to turn it back into Python.
|
|
679
|
+
- Regex searches have no timeout, so avoid patterns from untrusted sources on large files.
|
|
680
|
+
|
|
681
|
+
---
|
|
682
|
+
|
|
683
|
+
### AI / LLM utilities (3 tools)
|
|
684
|
+
|
|
685
|
+
These tools use Python's standard library for HTTP, so no extra package is needed. They do not run
|
|
686
|
+
automatically: the default provider is a local Ollama server at `http://localhost:11434`, using
|
|
687
|
+
model `llama3.2`.
|
|
688
|
+
|
|
689
|
+
Install and start Ollama, then download the default model:
|
|
690
|
+
|
|
691
|
+
```bash
|
|
692
|
+
ollama pull llama3.2
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
Summarize a document, choose a style, extract named fields as JSON, or classify text into your own
|
|
696
|
+
labels:
|
|
697
|
+
|
|
698
|
+
```bash
|
|
699
|
+
simplutils ai-summarize -f article.txt --style bullets
|
|
700
|
+
simplutils ai-summarize "A short passage to summarize." --style brief
|
|
701
|
+
simplutils ai-extract-json -f invoice.txt --fields vendor,total,date
|
|
702
|
+
simplutils ai-classify -f feedback.txt --labels positive,neutral,negative
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
To use OpenAI or another OpenAI-compatible chat-completions service, set the API key in the
|
|
706
|
+
environment and choose a model. Do not put keys directly in command arguments:
|
|
707
|
+
|
|
708
|
+
```powershell
|
|
709
|
+
$env:SIMPLUTILS_AI_API_KEY = "your-api-key"
|
|
710
|
+
simplutils ai-summarize -f article.txt --provider openai --model gpt-4o-mini
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
```bash
|
|
714
|
+
export SIMPLUTILS_AI_API_KEY="your-api-key"
|
|
715
|
+
simplutils ai-summarize -f article.txt --provider openai --model gpt-4o-mini
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
For OpenAI-compatible servers (including local servers), configure the API root with
|
|
719
|
+
`SIMPLUTILS_AI_BASE_URL`, or pass `--base-url`. `SIMPLUTILS_AI_MODEL` can supply a default model;
|
|
720
|
+
`--model` overrides it. The provider can also be set per command with `--provider ollama` or
|
|
721
|
+
`--provider openai`. Requests have a 60-second default timeout (adjust with `--timeout`) and limit
|
|
722
|
+
the generated output with `--max-tokens`.
|
|
723
|
+
|
|
724
|
+
| Tool | Behavior |
|
|
725
|
+
|---|---|
|
|
726
|
+
| `ai-summarize` | `--style brief\|bullets\|detailed` controls the summary format |
|
|
727
|
+
| `ai-extract-json` | `--fields name,email,amount` asks for exactly those JSON keys; invalid JSON or unexpected keys are reported as errors |
|
|
728
|
+
| `ai-classify` | `--labels positive,neutral,negative` restricts the result to one of the supplied labels |
|
|
729
|
+
|
|
730
|
+
These are model-generated results, not guaranteed facts. Review output before relying on it.
|
|
731
|
+
Choosing `--provider openai` sends the input text to that remote service; check its data-handling
|
|
732
|
+
terms first. The default Ollama endpoint is local; a custom `--base-url` can send it elsewhere.
|
|
733
|
+
The tool logs record metadata such as input size, not prompt or response contents. For sensitive text, consider
|
|
734
|
+
`pii-scan` and `pii-redact` first, and review the redacted result before sending it.
|
|
735
|
+
|
|
736
|
+
The same functions are available from Python:
|
|
737
|
+
|
|
738
|
+
```python
|
|
739
|
+
eu.ai_summarize("Long text to summarize.", style="brief")
|
|
740
|
+
eu.ai_extract_json("Ada is 37.", fields="name,age")
|
|
741
|
+
eu.ai_classify("I loved the service.", labels="positive,neutral,negative")
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
---
|
|
745
|
+
|
|
746
|
+
## 6. Recipes (real-world workflows)
|
|
747
|
+
|
|
748
|
+
**Clean a log before pasting it into a chat, ticket, or AI assistant**
|
|
749
|
+
|
|
750
|
+
```bash
|
|
751
|
+
simplutils pii-scan -f app.log # what's in there? (values hidden)
|
|
752
|
+
simplutils pii-redact -f app.log -o clean.log # emails, cards, keys, passwords become [LABELS]
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
Review `clean.log` before sharing. Detection is heuristic ([limits](#10-pii-redaction-what-it-does-and-doesnt-do)).
|
|
756
|
+
|
|
757
|
+
**See what changed between two config files**
|
|
758
|
+
|
|
759
|
+
```bash
|
|
760
|
+
simplutils json-diff old.json new.json # structural: shows paths like database.host
|
|
761
|
+
simplutils diff old.txt new.txt # line by line
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
**Turn photos into one PDF, then trim it**
|
|
765
|
+
|
|
766
|
+
```bash
|
|
767
|
+
simplutils image-to-pdf scan1.jpg scan2.jpg scan3.jpg -o scans.pdf
|
|
768
|
+
simplutils pdf-extract scans.pdf --pages 1,3 -o selected.pdf
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
**Shrink images for a website**
|
|
772
|
+
|
|
773
|
+
```bash
|
|
774
|
+
simplutils image-resize hero.png --width 1600 -o hero_1600.png
|
|
775
|
+
simplutils image-convert hero_1600.png --to webp --quality 80 -o hero.webp
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
**Embed a PDF or image in a JSON API request**
|
|
779
|
+
|
|
780
|
+
```bash
|
|
781
|
+
simplutils pdf-to-b64 invoice.pdf -o invoice.b64 # use the file contents as a JSON string value
|
|
782
|
+
simplutils image-to-b64 logo.png --data-uri -o logo.uri # ready for <img src="..."> or CSS url(...)
|
|
783
|
+
```
|
|
784
|
+
|
|
785
|
+
**Debug a login token**
|
|
786
|
+
|
|
787
|
+
```bash
|
|
788
|
+
simplutils jwt-decode "<paste token>" # who is it for, and has it expired?
|
|
789
|
+
simplutils ts-to-date 1700000000 # what time is this timestamp?
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
**Convert a spreadsheet export into an API payload**
|
|
793
|
+
|
|
794
|
+
```bash
|
|
795
|
+
simplutils csv-to-json -f export.csv --infer-types -o payload.json
|
|
796
|
+
simplutils json-to-yaml -f payload.json
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
**Make a QR code for a Wi-Fi network** (the text is the standard Wi-Fi format)
|
|
800
|
+
|
|
801
|
+
```bash
|
|
802
|
+
simplutils qr-generate "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;" -o wifi.png
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
**Build a repeatable step into a script**
|
|
806
|
+
|
|
807
|
+
```bash
|
|
808
|
+
simplutils pii-redact -f in.log -o out.log || exit 1 # exit code 0 = success, 1 = problem
|
|
809
|
+
```
|
|
810
|
+
|
|
811
|
+
---
|
|
812
|
+
|
|
813
|
+
## 7. Using it as a Python library
|
|
814
|
+
|
|
815
|
+
```python
|
|
816
|
+
import simplutils as eu
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
Every tool is a function with the same name as the command, using underscores:
|
|
820
|
+
|
|
821
|
+
```python
|
|
822
|
+
eu.b64_encode("hello world") # 'aGVsbG8gd29ybGQ='
|
|
823
|
+
eu.hash_text("hello", algo="sha256") # 2cf24dba...
|
|
824
|
+
eu.hmac_text("message", key="secret")
|
|
825
|
+
eu.json_diff([before_bytes, after_bytes]) # "~ version: ..."
|
|
826
|
+
eu.pii_redact("mail a@x.com", mode="hash") # e.g. 'mail [EMAIL#83c61eca]' (token differs per run)
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
Function names differ slightly from the command in a few places: `hash` → `hash_text`,
|
|
830
|
+
`hmac` → `hmac_text`, `uuid` → `uuid_gen`, `diff` → `text_diff`. See `simplutils.TOOLS`
|
|
831
|
+
for the full list.
|
|
832
|
+
|
|
833
|
+
### Tools that take or return files
|
|
834
|
+
|
|
835
|
+
- A tool that takes **one file** receives `bytes`; one that takes **several** receives a
|
|
836
|
+
`list` of `bytes`.
|
|
837
|
+
- A tool that **makes a file** returns a `FileResult` with `.data` (bytes), `.filename` and `.mime`.
|
|
838
|
+
|
|
839
|
+
```python
|
|
840
|
+
from pathlib import Path
|
|
841
|
+
import simplutils as eu
|
|
842
|
+
|
|
843
|
+
png = Path("photo.png").read_bytes()
|
|
844
|
+
|
|
845
|
+
small = eu.image_resize(png, width=800) # FileResult
|
|
846
|
+
Path(small.filename).write_bytes(small.data) # 'resized.png'
|
|
847
|
+
|
|
848
|
+
merged = eu.pdf_merge([Path("a.pdf").read_bytes(), Path("b.pdf").read_bytes()])
|
|
849
|
+
Path("merged.pdf").write_bytes(merged.data)
|
|
850
|
+
|
|
851
|
+
pages = eu.pdf_extract(Path("book.pdf").read_bytes(), pages="1-3,10")
|
|
852
|
+
b64 = eu.pdf_to_b64(Path("book.pdf").read_bytes()) # str
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
### Errors
|
|
856
|
+
|
|
857
|
+
Bad input raises `simplutils.ToolError` with a readable message (never a cryptic traceback):
|
|
858
|
+
|
|
859
|
+
```python
|
|
860
|
+
try:
|
|
861
|
+
eu.b64_decode("not base64!!!")
|
|
862
|
+
except eu.ToolError as e:
|
|
863
|
+
print(e) # invalid Base64 (try the urlsafe option?): Only base64 data is allowed
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
### Running a tool by name
|
|
867
|
+
|
|
868
|
+
```python
|
|
869
|
+
eu.TOOLS["hash"].run("hello", algo="md5") # '5d41402a...' (also logged)
|
|
870
|
+
for name, tool in eu.TOOLS.items():
|
|
871
|
+
print(name, "-", tool.description)
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
Calling `eu.hash_text(...)` directly is the plain function; `TOOLS[name].run(...)` additionally
|
|
875
|
+
validates options, applies defaults, and writes the log entry.
|
|
876
|
+
|
|
877
|
+
A runnable tour of the library is in [`examples/library_tour.py`](examples/library_tour.py) and of
|
|
878
|
+
the command line in [`examples/cli_tour.py`](examples/cli_tour.py), with sample files in
|
|
879
|
+
[`examples/sample_data/`](examples/sample_data/).
|
|
880
|
+
|
|
881
|
+
---
|
|
882
|
+
|
|
883
|
+
## 8. The web UI
|
|
884
|
+
|
|
885
|
+
```bash
|
|
886
|
+
pip install "simplutils[ui]"
|
|
887
|
+
simplutils ui # opens http://localhost:8080
|
|
888
|
+
simplutils ui --port 9000 # another port
|
|
889
|
+
simplutils ui --no-browser # don't open a browser window
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
A searchable sidebar lists every tool. Type or paste into the input box and the result updates
|
|
893
|
+
live; options appear as drop-downs and switches. File tools have an upload box (with an image
|
|
894
|
+
preview), multi-file tools take several uploads in order, and tools that make files show a
|
|
895
|
+
**Download file** button. There is a dark-mode toggle.
|
|
896
|
+
|
|
897
|
+
It runs a small server **on your own machine only**: nothing is hosted. Regular tools process data
|
|
898
|
+
locally; AI tools follow the provider and endpoint you select, as described in the AI section.
|
|
899
|
+
Use the search box at the top of the sidebar to find any tool.
|
|
900
|
+
|
|
901
|
+
---
|
|
902
|
+
|
|
903
|
+
## 9. Logging and privacy
|
|
904
|
+
|
|
905
|
+
Every run is recorded in a rotating log file (1 MB, 3 backups):
|
|
906
|
+
|
|
907
|
+
| | |
|
|
908
|
+
|---|---|
|
|
909
|
+
| Default location | `~/.simplutils/simplutils.log` (on Windows: `C:\Users\<you>\.simplutils\simplutils.log`) |
|
|
910
|
+
| Change the folder | set the environment variable `simplutils_LOG_DIR` |
|
|
911
|
+
|
|
912
|
+
```bash
|
|
913
|
+
simplutils logs # last 20 lines
|
|
914
|
+
simplutils logs -n 100
|
|
915
|
+
simplutils logs --path # where is the file?
|
|
916
|
+
simplutils -v hash abc # also show log messages on screen
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
```text
|
|
920
|
+
2026-11-11 11:32:36,828 INFO tool=jwt-decode ok in=41 chars options={} out=77 chars time=0ms
|
|
921
|
+
2026-11-11 11:40:02,114 WARNING tool=b64-decode failed: invalid Base64 ...
|
|
922
|
+
```
|
|
923
|
+
|
|
924
|
+
**What is logged:** the tool name, the input *size*, non-text options (like `algo`), the output
|
|
925
|
+
size, timing, and success or failure.
|
|
926
|
+
**What is never logged:** the text or files you process. Free-text options such as an HMAC key
|
|
927
|
+
are written as `<hidden>`. The PII tools log only counts per type
|
|
928
|
+
(`pii-redact: 3 finding(s) {'email': 2, 'phone': 1}`), never values.
|
|
929
|
+
|
|
930
|
+
If a tool crashes unexpectedly you see a short message and the full details go to the log.
|
|
931
|
+
If the log folder can't be written (read-only profile), the tools still work; logging is skipped.
|
|
932
|
+
When you use `simplutils` as a library, nothing is logged unless your own program calls
|
|
933
|
+
`simplutils.logs.setup_logging()`.
|
|
934
|
+
|
|
935
|
+
---
|
|
936
|
+
|
|
937
|
+
## 10. PII redaction: what it does and doesn't do
|
|
938
|
+
|
|
939
|
+
**Detects** (run `simplutils pii-types`):
|
|
940
|
+
|
|
941
|
+
| Type | Notes |
|
|
942
|
+
|---|---|
|
|
943
|
+
| `email`, `ip-address` | IPv4. Version strings like `1.2.3.4.5` are not flagged |
|
|
944
|
+
| `phone` | India mobile, US/Canada, and international `+CC ...` formats |
|
|
945
|
+
| `credit-card` | Luhn-checked, so random digit strings are ignored |
|
|
946
|
+
| `iban` | mod-97 checked |
|
|
947
|
+
| `aadhaar` | Verhoeff-checked (India) |
|
|
948
|
+
| `pan` | Indian PAN format `ABCDE1234F` |
|
|
949
|
+
| `ssn` | US Social Security Number format |
|
|
950
|
+
| `password` | `password=...`, `secret: ...`, `api_key = ...` style assignments |
|
|
951
|
+
| `bearer-token`, `jwt`, `url-password` | Authorization headers, JWTs, `https://user:PASS@host` |
|
|
952
|
+
| `aws-key`, `github-token`, `slack-token`, `google-api-key`, `private-key` | Common credential formats |
|
|
953
|
+
|
|
954
|
+
**Modes** for `pii-redact`:
|
|
955
|
+
|
|
956
|
+
| `--mode` | Result for `jo@example.com` | Notes |
|
|
957
|
+
|---|---|---|
|
|
958
|
+
| `label` (default) | `[EMAIL]` | Safest and easiest to read |
|
|
959
|
+
| `mask` | `**@******e.com` (last 4 letters/digits kept) | IDs and cards keep their last 4 characters; secrets are fully masked |
|
|
960
|
+
| `hash` | `[EMAIL#3f9a1c2b]` | The same value gets the same token **within one run**, so you can still follow "the same user" across a log. The salt is random per run, so tokens can't be matched across runs or brute-forced |
|
|
961
|
+
|
|
962
|
+
`--only email,phone` limits what is replaced; `--exclude phone` skips a type. A type you switch
|
|
963
|
+
off still "claims" its text, so it can't be re-reported as something else (excluding
|
|
964
|
+
`credit-card` does not turn the same digits into a `phone`).
|
|
965
|
+
|
|
966
|
+
**Limits. Please read:**
|
|
967
|
+
|
|
968
|
+
- Detection is **heuristic** (patterns plus checksums). It will **not** find people's names,
|
|
969
|
+
addresses, or free text such as "my password is blue horse". It is a safety net, not a guarantee.
|
|
970
|
+
**Always review before sharing sensitive text.**
|
|
971
|
+
- Some 10-digit numbers can look like phone numbers. If that bites, use `--exclude phone`.
|
|
972
|
+
- It works on **text**. PDFs and Word files are not supported yet. Extract the text first
|
|
973
|
+
(`simplutils pdf-text`), then redact it.
|
|
974
|
+
|
|
975
|
+
---
|
|
976
|
+
|
|
977
|
+
## 11. Troubleshooting and FAQ
|
|
978
|
+
|
|
979
|
+
**`simplutils` is "not recognized" (Windows).** The Python *Scripts* folder isn't on your PATH.
|
|
980
|
+
Either use `python -m simplutils ...`, or install with `pipx install "simplutils[all]"`, which
|
|
981
|
+
handles PATH for you.
|
|
982
|
+
|
|
983
|
+
**"this tool needs Pillow / pypdf / PyYAML / segno: pip install simplutils[...]".** You're using a
|
|
984
|
+
tool from an optional group. Install the extra it names, or `pip install "simplutils[all]"`.
|
|
985
|
+
|
|
986
|
+
**Inline JSON fails in Windows PowerShell** (`invalid JSON: Expecting property name enclosed in
|
|
987
|
+
double quotes`). Windows PowerShell 5.1 strips the inner double quotes when it passes arguments to
|
|
988
|
+
programs. Any of these work:
|
|
989
|
+
|
|
990
|
+
```powershell
|
|
991
|
+
'{"a":1}' | simplutils json-format # pipe it (recommended)
|
|
992
|
+
simplutils json-format -f data.json # or read a file
|
|
993
|
+
simplutils json-format '{\"a\":1}' # or escape the quotes with backslashes
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
PowerShell 7 and Command Prompt/Git Bash don't have this problem.
|
|
997
|
+
|
|
998
|
+
**A file saved by Notepad / PowerShell won't load.** It should: UTF-8 with or without a BOM and
|
|
999
|
+
UTF-16 (what PowerShell's `>` writes) are all handled. If you see `not valid UTF-8 text`, the file
|
|
1000
|
+
is binary or in an older encoding (such as Windows-1252). Re-save it as UTF-8.
|
|
1001
|
+
|
|
1002
|
+
**Non-English text through a PowerShell pipe looks garbled.** Windows PowerShell 5.1 pipes text
|
|
1003
|
+
using an old code page. Pass the text as an argument, or use `-f file`.
|
|
1004
|
+
|
|
1005
|
+
**"the PDF is password-protected".** Decrypt it first (not supported yet).
|
|
1006
|
+
|
|
1007
|
+
**`pdf-text` returns "no text found".** The PDF is probably a scan (pictures of pages). It has no
|
|
1008
|
+
text layer to extract; OCR is not included.
|
|
1009
|
+
|
|
1010
|
+
**Where did my output file go?** Next to where you ran the command. Tools that make files print
|
|
1011
|
+
`saved N bytes to <path>`. Use `-o path` to choose.
|
|
1012
|
+
|
|
1013
|
+
**Is anything sent over the network?** Regular tools process data locally. AI tools only make a
|
|
1014
|
+
request when invoked: Ollama defaults to a local endpoint; the OpenAI-compatible provider sends
|
|
1015
|
+
the input text to the endpoint you configure. `pip install` also downloads packages.
|
|
1016
|
+
|
|
1017
|
+
**Can I run it from a script or CI?** Yes. Use the exit codes in section 4, or the Python library.
|
|
1018
|
+
|
|
1019
|
+
---
|
|
1020
|
+
|
|
1021
|
+
## 12. Extending: add your own tool
|
|
1022
|
+
|
|
1023
|
+
A tool is **one decorated function**. The command, menu entry, web page and log entries are all
|
|
1024
|
+
generated from it automatically.
|
|
1025
|
+
|
|
1026
|
+
```python
|
|
1027
|
+
# src/simplutils/tools/mytools.py
|
|
1028
|
+
from ..registry import tool, ToolError
|
|
1029
|
+
|
|
1030
|
+
@tool("reverse", "Reverse Text", "Text") # command name, display title, group
|
|
1031
|
+
def reverse(text: str, words: bool = False) -> str:
|
|
1032
|
+
"""Reverse the text (or just the order of words).""" # first line = the help text
|
|
1033
|
+
if not text:
|
|
1034
|
+
raise ToolError("nothing to reverse")
|
|
1035
|
+
return " ".join(reversed(text.split())) if words else text[::-1]
|
|
1036
|
+
```
|
|
1037
|
+
|
|
1038
|
+
Then add `mytools` to the import list in `src/simplutils/tools/__init__.py`. Done:
|
|
1039
|
+
`simplutils reverse "abc"` → `cba`.
|
|
1040
|
+
|
|
1041
|
+
Rules:
|
|
1042
|
+
|
|
1043
|
+
- The **first parameter** decides the input: `text` (text), `data` (one file as `bytes`),
|
|
1044
|
+
`files` (a `List[bytes]`). No such parameter means no input.
|
|
1045
|
+
- Other parameters are **options**: `str`, `int`, `bool` (must default to `False`), or
|
|
1046
|
+
`Literal["a", "b"]` for a choice list. A parameter with no default is required.
|
|
1047
|
+
- Return a string, or a `FileResult(data, filename, mime)` for a file.
|
|
1048
|
+
- Raise `ToolError("friendly message")` for bad input.
|
|
1049
|
+
|
|
1050
|
+
---
|
|
1051
|
+
|
|
1052
|
+
## 13. Development and releasing
|
|
1053
|
+
|
|
1054
|
+
```bash
|
|
1055
|
+
pip install -e ".[all,dev]" # editable install with everything
|
|
1056
|
+
python -m pytest # run the tests
|
|
1057
|
+
python examples/library_tour.py # try the examples
|
|
1058
|
+
```
|
|
1059
|
+
|
|
1060
|
+
Project layout:
|
|
1061
|
+
|
|
1062
|
+
```text
|
|
1063
|
+
src/simplutils/
|
|
1064
|
+
registry.py the @tool decorator and registry
|
|
1065
|
+
cli.py command line (generated from the registry)
|
|
1066
|
+
interactive.py the step-by-step menu
|
|
1067
|
+
ui.py the web UI (generated from the registry)
|
|
1068
|
+
logs.py logging
|
|
1069
|
+
textio.py robust text-file reading (BOM / UTF-16)
|
|
1070
|
+
tools/ one module per group of tools
|
|
1071
|
+
tests/ pytest tests
|
|
1072
|
+
examples/ runnable tours and sample data
|
|
1073
|
+
```
|
|
1074
|
+
|
|
1075
|
+
To publish the source on GitHub and make `python -m pip install simplutils` available to everyone,
|
|
1076
|
+
follow **[PUBLISHING.md](PUBLISHING.md)**. The PyPI install command works after the first successful
|
|
1077
|
+
release; until then, install from the project folder with `python -m pip install -e .`.
|
|
1078
|
+
|
|
1079
|
+
## License
|
|
1080
|
+
|
|
1081
|
+
MIT. See [LICENSE](LICENSE).
|