humidifier
Create human-friendly IDs from strings.
The typical use case for humidifier is that you have some string (a word, a name, a phrase...) that you want to turn into a human-friendly ID.
For example, your project has URLs containing IDs, and it would be nicer to have /record/an-example instead of /record/21937218.
Such IDs are easy to remember and can function as a preview for the database entry.
This can be achieved with the excellent python-slugify, to which humidifier adds the option to generate unique IDs
Usage
Using humidifier is rather simple:
from humidifier import humidify
id_1 = humidify("dog", unique=True) # 'dog'
id_2 = humidify("dog", unique=True) # 'dog-1'
id_3 = humidify("dög", unique=True) # 'dog-2'
id_4 = humidify("ʔɚ", unique=True) # 'null'
id_5 = humidify("ʔɚ", unique=True) # 'null-1'
If your strings come from different populations that you would like to keep distinct in the generated IDs, there is an optional key argument:
from humidifier import humidify
id_1 = humidify("dog", key="animals", unique=True) # 'dog'
id_2 = humidify("dog", key="quadripeds", unique=True) # 'dog'
id_3 = humidify("dög", key="animals", unique=True) # 'dog-1'
id_4 = humidify("dög", key="animals", unique=True) # 'dog-2'
If you are working with an existing set of IDs:
from humidifier import Humidifier
hum = Humidifier(["dog"])
hum.humidify("dog", unique=True) # 'dog-1'
If you only want to generate a new ID for each distinct string:
from humidifier import humidify
humidify("dög") # 'dog'
humidify("dög") # 'dog'
humidify("dog") # 'dog-1'
You can also use any of the arguments described for python-slugify.
The arguments max_length for truncating, separator for something other than - in between parts, and replacements may be of particular interest when generating IDs.
Metadata
Release files for humidifier 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| humidifier-0.0.2.tar.gz | 7.9 kB | Without provenance | Details for humidifier-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| humidifier-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for humidifier-0.0.2-py3-none-any.whl |
Total release size: 15.3 kB
Release files / humidifier-0.0.2.tar.gz
| Download URL | humidifier-0.0.2.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
119307cda9453fe1b4e6d5ffd91c18730cc3d525f54cd2ab375a0a2a8c9a7a1c
|
|
BLAKE2b-256 checksum How to use checksums |
2a4e28a7ab129e3e87fd497ae3efca452e9cd5e71b1e6fbba88bbfa50daba3c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.13
|
Release files / humidifier-0.0.2-py3-none-any.whl
| Download URL | humidifier-0.0.2-py3-none-any.whl |
|---|---|
| Size | 7.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a005299b1a001c0e80b7f8c530933da3163feb5da5ee4e0b0a324246585c2a9c
|
|
BLAKE2b-256 checksum How to use checksums |
fb104f34f1ccc13cd9518acb993c35214e8b7830dee2e7359dfebc09841f2263
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.13
|
Security for humidifier 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.