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.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28b988e97da6fe8964880449396633dd7d392684c5e33b206088f9a5942fd83c |
|
MD5 | 9c42ca0517e199ce42e18f0b278b6d6d |
|
BLAKE2b-256 | 046eeb78cbf31e6bb74132f64f5173cdc3ef3769e3243c92317da290e5e48797 |