snakecamel
A small utility to camelize (convert to camel-case) or snakeize (convert to snake-case) any object.
This is a very early-stage project & for the time-being is only there as a personal utility.
Usage
import snakecamel
>>> snakecamel.camelize("simple_string")
'simpleString
>>> snakecamel.snakeize("simpleString")
'simple_string'
General notes
- The library is designed to be very forgiving. It does not raise upon encountering an unknown type, it just skips it. This way, you can pass arbitrary objects to it & everything that can be camelized/snakeized, will be.
>>> import snakecamel
>>> snakecamel.camelize(50)
50
>>> from datetime import date
>>> snakecamel.camelize({"hello_world": "hello_world", 50: 50, date.today(): "today"})
{'helloWorld': 'hello_world', 50: 50, datetime.date(2022, 7, 31): 'today'}
- The library will try to re-construct the type you pass to it, so that if you pass different kinds of iterables, you'll get the same type returned. Unfortunately, that still does not work with mappings.
>>> import snakecamel
>>> snakecamel.camelize(["simple_string"])
['simpleString']
>>> snakecamel.camelize({"simple_string"})
{'simpleString'}
>>> snakecamel.camelize(("simple_string",))
('simpleString',)
>>> snakecamel.camelize("simple_string")
'simpleString'
- When camelizing/snakeizing mappings, you can choose to do so with keys only or keys & values.
>>> import snakecamel
>>> snakecamel.camelize({"simple_key": "simple_value"})
{'simpleKey': 'simple_value'}
>>> snakecamel.camelize({"simple_key": "simple_value"}, camelize_mapping_values=True)
{'simpleKey': 'simpleValue'}
- You can shoose between capitalized or non-capitalized camel case.
>>> import snakecamel
>>> snakecamel.camelize("simple_string")
'simpleString'
>>> snakecamel.camelize("simple_string", capitalized=True)
'SimpleString'
When snakeizing, you need to pass capitalized=True, if you want the first letter of a
capitalized camel-case word to be lowercased.
>>> snakecamel.snakeize("simpleString")
'simple_string'
>>> snakecamel.snakeize("simpleString", capitalized=True)
'simple_string'
>>> snakecamel.snakeize("SimpleString")
'Simple_string'
>>> snakecamel.snakeize("SimpleString", capitalized=True)
'simple_string'
- When camelizing, you can choose whether you're stripping leading/trailing underscores or not.
import snakecamel
>>> import snakecamel
>>> snakecamel.camelize("_simple_string_")
'_simpleString_'
>>> snakecamel.camelize("_simple_string_", strip_underscores=True)
'simpleString'
Metadata
Release files for snakecamel 0.1.0
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 |
|---|---|---|---|---|
| snakecamel-0.1.0.tar.gz | 4.6 kB | Without provenance | Details for snakecamel-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snakecamel-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for snakecamel-0.1.0-py3-none-any.whl |
Total release size: 9.6 kB
Release files / snakecamel-0.1.0.tar.gz
| Download URL | snakecamel-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cab2fb350d11798f4866327261adc1079c1fc6f6fe1077e8624542a63766b767
|
|
BLAKE2b-256 checksum How to use checksums |
6afe3571bf8036a73e229d3080e67b79c90bfd3499f93bc1d0ecab95afe57a5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.4 Linux/5.15.0-41-generic
|
Release files / snakecamel-0.1.0-py3-none-any.whl
| Download URL | snakecamel-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
79a004695db91ad6138a5afd91f0ca7499709a438fcc031c5aa81b6c043ef547
|
|
BLAKE2b-256 checksum How to use checksums |
35171edac0df3dec425068ded36e058b274f5e45608ca94702f0d13ec982f403
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.14 CPython/3.10.4 Linux/5.15.0-41-generic
|
Security for snakecamel 0.1.0
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.