A string case conversion package.
Project description
Case Converter
A robust python package for transforming string cases such as Hello, world!
into
helloWorld
(camelcase).
General usage
Import a case conversion helper function, or the conversion object itself.
from caseconverter import camelcase, Camel
camelcase("Hello, world!") # output: helloWorld
Camel("Hello, world!").convert() # output: helloWorld
By default, case conversion takes into consideration 2 boundary conditions for token separation.
- Delimiters.
- Lowercase char followed by an uppercase char.
The action taken when a boundary is identified depends on the case conversion.
If the input string is all uppercase it can only be processed based on delimiters.
Customizing delimiters
Default delimiters used to denote a token boundary.
# Default delimiters
DELIMITERS = " -_"
You can pass delims
to each case conversion function to specify a custom
set of delimiters.
from caseconverter import camelcase
# Use a pipe `|` as the only delimiter.
camelcase("Hello,|world!", delims="|") # output: helloWorld
Stripping punctuation
Generally, punctuation is stripped when doing a case conversion. However, should you
wish to keep the punctuation you can do so by passing strip_punctuation=False
.
from caseconverter import camelcase
camelcase("Hello, world!", strip_punctuation=False) # output: hello,World!
Available conversions
camelcase
from caseconverter import camelcase
camelcase("Hello, world!")
helloWorld
pascalcase
from caseconverter import pascalcase
pascalcase("Hello, world!")
HelloWorld
snakecase
from caseconverter import snakecase
snakecase("Hello, world!")
hello_world
flatcase
from caseconverter import flatcase
flatcase("Hello, world!")
helloworld
kebabcase
from caseconverter import kebabcase
kebabcase("Hello, world!")
hello-world
cobolcase
from caseconverter import cobolcase
cobolcase("Hello, world!")
HELLO-WORLD
macrocase
from caseconverter import macrocase
macrocase("Hello, world!")
HELLO_WORLD
Contributing
- Write clean code.
- Write new tests for new use-cases.
- Test your code before raising a PR.
- Use black to format your code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file case-converter-1.0.3.tar.gz
.
File metadata
- Download URL: case-converter-1.0.3.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f4c6ed0071001a219e636e03c388a5e79398c710c033cc6aa3a40985c855cf6 |
|
MD5 | d721ab180d8d86f879b3bb1d1971838d |
|
BLAKE2b-256 | fdca1f75f8306e1d25073e62001cbccbe2e4e9da238897de0d6b213ef2cebfad |
File details
Details for the file case_converter-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: case_converter-1.0.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.1 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ea857f28f7f2c3f19f7bc1746d84399dc8840044c91b48ee20f103b4de8d767 |
|
MD5 | 26c785630fa3b707661b86ed2acc9d18 |
|
BLAKE2b-256 | 31958c6ac8aca980062fad234e7b52d36feeb79c1e3c7fc121531682cfc02481 |