Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

case-converter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

case-converter

A string case conversion package.

  • 1.1.0
  • PyPI
  • Socket score

Maintainers
1

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

NameDescription
OnDelimeterUppercaseNextOn a delimieter, upper case the following character
OnDelimeterLowercaseNextOn a delimeter, lower case the following character
OnUpperPrecededByLowerAppendUpperOn an upper case character followed by a lower case character, append the upper case character
OnUpperPrecededByLowerAppendLowerOn an upper case character preceeded by a lower case character append the lower case character
OnUpperPrecededByUpperAppendJoinOn an upper case caharacter preceeded by an upper append the join character. Join characters are context dependent. Example: macro cast join character is _
OnUpperPrecededByUpperAppendCurrentOn 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.

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc