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

from caseconverter import camelcase

camelcase("Hello, world!") # output: helloWorld

Delimeter behavior

If multiple delimeter characters are identified next to eachother they will be considered as a single delimeter. For example, -_ contains 2 different delimeter characters and is considered a single delimeter.

Available conversions

camelcase

from caseconverter import camelcase

camelcase("Hello, world!")
helloWorld

cobolcase

from caseconverter import cobolcase

cobolcase("Hello, world!")
HELLO-WORLD

flatcase

from caseconverter import flatcase

flatcase("Hello, world!")
helloworld

kebabcase

from caseconverter import kebabcase

kebabcase("Hello, world!")
hello-world

macrocase

from caseconverter import macrocase

macrocase("Hello, world!")
HELLO_WORLD

Additional options

delims_only : bool - Only consider delimiters as boundaries (default: False).

pascalcase

from caseconverter import pascalcase

pascalcase("Hello, world!")
HelloWorld

snakecase

from caseconverter import snakecase

snakecase("Hello, world!")
hello_world

Options for all conversions

Stripping punctuation

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.

camelcase("Hello, world!", strip_punctuation=False) # output: hello,World!

Delimeter customization

Default delimiters used to denote a token boundary.

DELIMITERS = " -_"

You can pass delims to each case conversion function to specify a custom set of delimiters.

# Use a pipe `|` as the only delimiter.
camelcase("Hello,|world!", delims="|") # output: helloWorld

Boundaries definitions

Name Description
OnDelimeterUppercaseNext On a delimieter, upper case the following character
OnDelimeterLowercaseNext On a delimeter, lower case the following character
OnUpperPrecededByLowerAppendUpper On an upper case character followed by a lower case character, append the upper case character
OnUpperPrecededByLowerAppendLower On an upper case character preceeded by a lower case character append the lower case character
OnUpperPrecededByUpperAppendJoin On an upper case caharacter preceeded by an upper append the join character. Join characters are context dependent. Example: macro cast join character is _
OnUpperPrecededByUpperAppendCurrent On an upper case character preceeded by an upper case character append the upper case character

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.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

case_converter-1.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: case-converter-1.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for case-converter-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2ed3fc6e3ffa8d601f9a31ffcbc8fbd19eaeb48671a79a8ef16394672824510e
MD5 bf3c3631c3d1db44a46ee589a52ad2d7
BLAKE2b-256 76d948a4f2bb0dbea1086836a25b64ba77f5ab23652a12f45d9bbd2fe3f13d35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for case_converter-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0fbc665a4fd410e454630bcf5168dce62e147a98512647ed48b0a6b556986e3
MD5 baa12246329aac17950657d43f0c9182
BLAKE2b-256 b93220d0de7482c40aff9b42002b98a169adcaf0e5e50b59278e8f6405361278

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