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
Hashes for case_converter-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07142bf3f569c930a0baff40cb6c2047c7ca67ca741fb4e37adae4b8f3615fe7 |
|
MD5 | 3d6d46d84e9a95792de3d2ced21cecb4 |
|
BLAKE2b-256 | 92b5d0ba182eb45d1643bad8efe0854226032beda4de9c7e03338f94157449ba |