Skip to main content

A string case conversion package.

Project description

Case Converter

pipline wheel coverage license

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.

  1. Delimiters.
  2. 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

  1. Write clean code.
  2. Write new tests for new use-cases.
  3. Test your code before raising a PR.
  4. Use black to format your code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

case-converter-1.0.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

case_converter-1.0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file case-converter-1.0.2.tar.gz.

File metadata

  • Download URL: case-converter-1.0.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for case-converter-1.0.2.tar.gz
Algorithm Hash digest
SHA256 f441019f10a777e2e8fac3b27833766851b68e1f2bdcf5cff3eeba5cffad7294
MD5 0a8e71fabc2e13bee38cfac32a68562c
BLAKE2b-256 39cabf8296d24c4ae45c19f47ab28494b87532d7d6ef001b77bf98de34906d71

See more details on using hashes here.

File details

Details for the file case_converter-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: case_converter-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for case_converter-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 07142bf3f569c930a0baff40cb6c2047c7ca67ca741fb4e37adae4b8f3615fe7
MD5 3d6d46d84e9a95792de3d2ced21cecb4
BLAKE2b-256 92b5d0ba182eb45d1643bad8efe0854226032beda4de9c7e03338f94157449ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page