Casey
A simple library to support various naming conventions and convert strings from one to another.
Casey supports:
- camelCase
- PascalCase
- kebab-case
- snake_case and SNAKE_CASE
Usage
Installation
pip install casey
Sample
import casey
subject = "every 1 WORD is very IMPORTANT"
print(casey.camel(subject))
# Prints: every1WORDIsVeryIMPORTANT
print(casey.kebab(subject))
# Prints: every-1-WORD-is-very-IMPORTANT
print(casey.pascal(subject))
# Prints: Every1WORDIsVeryIMPORTANT
print(casey.snake(subject))
# Prints: every_1_WORD_is_very_IMPORTANT
print(casey.snake(subject, upper=True))
# Prints: EVERY_1_WORD_IS_VERY_IMPORTANT
def my_transformation(word: str, idx: int) -> str:
if idx % 2 == 0:
return word.lower()
else:
return word.upper()
print(casey.transform(subject, my_transformation, "_"))
# Prints: every_1_word_IS_very_IMPORTANT
API
-
clean(subject: str) -> str: ...Returns string with removed cases.
-
camel(subject: str) -> str: ...Returns string in camelCase.
-
pascal(subject: str) -> str: ...Returns string in PascalCase.
-
kebab(subject: str) -> str: ...Returns string in kebab-case.
-
snake(subject: str) -> str: ...Returns string in snake_case.
-
snake(subject: str, upper=False) -> str: ...Returns string in snake_case.
If
upperisTrue, it will convert whole subject to upper snake case. -
upper_first(subject: str) -> str: ...Returns string with upper first letter (A-Z).
-
lower_first(subject: str) -> str: ...Returns string with lower first letter (A-Z).
-
transform(subject: str, transformation: Callable, glue=" ") -> str: ...Returns string transformed by the transformation function. The transformation function accepts 2 parameters: current word index (int), and a word itself (str). Glue is the string used to concat transformed words into one string.
License
This project is licensed under Apache-2.0 License - see the LICENSE file for details.
Metadata
Release files for casey 1.2.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 |
|---|---|---|---|---|
| casey-1.2.0.tar.gz | 7.4 kB | Without provenance | Details for casey-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| casey-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for casey-1.2.0-py3-none-any.whl |
Total release size: 14.7 kB
Release files / casey-1.2.0.tar.gz
| Download URL | casey-1.2.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
216dd5fd74988c6037a7ea5ba45220a64c29b6bd8686e9355f009e589daa2097
|
|
BLAKE2b-256 checksum How to use checksums |
25d680aef41db435f335b556ec6816ab24e66af7e0a65fed7d0271205e581c29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.10 Linux/5.11.0-40-generic
|
Release files / casey-1.2.0-py3-none-any.whl
| Download URL | casey-1.2.0-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
df341a87b3766c627d4ead1843ef516a8267b8d55d6a2704db0185ef48c91b55
|
|
BLAKE2b-256 checksum How to use checksums |
cc8df56512afa02ad85aca65ce0bc6826268b782a8995b4fe539352b83a1c683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.10 Linux/5.11.0-40-generic
|
Security for casey 1.2.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.