Casefy (/keɪsfaɪ/) is a lightweight Python package to convert the casing of strings

Overview

Active Issues

Introduction

Casefy (/keɪsfaɪ/) is a lightweight Python package to convert the casing of strings. It has no third-party dependencies and supports Unicode.


Installation

The latest release can be installed using pip:

pip install -U casefy

Casefy is also available as an Arch Linux AUR package.


Examples

Note: for more details, you can check the API Reference.

import casefy

# camelCase
string = casefy.camelcase("foo_bar")
print(string)  # fooBar

string = casefy.camelcase("FooBar")
print(string)  # fooBar

string = casefy.camelcase("FOO BAR")
print(string)  # fooBar

# snake_case
string = casefy.snakecase("fooBar")
print(string)  # foo_bar

string = casefy.snakecase("fooBARbaz", keep_together=["bar"])
print(string)  # foo_bar_baz

string = casefy.snakecase("FOO BAR")
print(string)  # foo_bar

# CONST_CASE
string = casefy.constcase("fooBar")
print(string)  # FOO_BAR

# kebab-case
string = casefy.kebabcase("fooBar")
print(string)  # foo-bar

# separator case
string = casefy.separatorcase("fooBar", separator="/")
print(string)  # foo/bar

string = casefy.separatorcase("fooBARbaz", separator="%", keep_together=["bar"])
print(string)  # foo%bar%baz

# Sentence case
string = casefy.sentencecase("fooBar")
print(string)  # Foo bar

Contribute

If you find a bug, please open an issue. Pull Requests are also welcome!


Acknowledgements

This project started when I saw that the package python-stringcase was flagged-out-of-date in the Arch AUR Repository. The project stringcase seems not to be actively maintained anymore, so I decided to address its issues and pull requests and solve them in this new package. I kept the API as similar as possible, in order to facilitate any possible migration. I thank Taka Okunishi (author of stringcase) and its contributors for their work.


Related projects

  • case-conversion offers a very similar functionality as this project. I probably wouldn't have written this package if I had known of it before. However, the code of Casefy is more lightweight and just enough for most cases. If you need more functionality, e.g., detecting the case of a string, go with case-conversion.

  • Inflection presents some overlap with this project as well, allowing the transformation of strings from CamelCase to underscored_string, but also singularizing and pluralizing English words.


License

Casefy is distributed under the MIT license.

You might also like...
A Python package for floating-point binary fractions. Do math in base 2!

An implementation of a floating-point binary fractions class and module in Python. Work with binary fractions and binary floats with ease!

A Python package implementing various colour checker detection algorithms and related utilities.
A Python package implementing various colour checker detection algorithms and related utilities.

A Python package implementing various colour checker detection algorithms and related utilities.

Obsidian tools - a Python package for analysing an Obsidian.md vault

obsidiantools is a Python package for getting structured metadata about your Obsidian.md notes and analysing your vault.

A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use that mirror

Kali Mirror Finder Using Single Python File A python package for your Kali Linux distro that find the fastest mirror and configure your apt to use tha

The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

Fcpy: A Python package for high performance, fast convergence and high precision numerical fractional calculus computing.

Fcpy: A Python package for high performance, fast convergence and high precision numerical fractional calculus computing.

python package for generating typescript grpc-web stubs from protobuf files.

grpc-web-proto-compile NOTE: This package has been superseded by romnn/proto-compile, which provides the same functionality but offers a lot more flex

DUQ is a python package for working with physical Dimensions, Units, and Quantities.

DUQ is a python package for working with physical Dimensions, Units, and Quantities.

Personal Toolbox Package

Jammy (Jam) A personal toolbox by Qsh.zh. Usage setup For core package, run pip install jammy To access functions in bin git clone https://gitlab.com/

Releases(v0.1.7)
  • v0.1.7(Dec 27, 2022)

    Casefy

    v0.1.7

    What's Changed

    This release only includes changes in the packaging logic:

    • Remove legacy setup.cfg and setup.py.
    • Change to hatchling as build backend.
    • Update project metadata.

    Full Changelog: https://github.com/dmlls/python-casefy/compare/v0.1.2...v0.1.7

    Source code(tar.gz)
    Source code(zip)
  • v0.1.2(Mar 20, 2022)

    Casefy

    v0.1.2

    What's Changed

    • Added py.typed to enable exported typing by @rob-blackbourn in https://github.com/dmlls/python-casefy/pull/1
    • With https://github.com/dmlls/python-casefy/commit/261c7827ff4fe88304cba7e5caf554f230fc4add, the casefy module no longer exposes re and typing.List

    New Contributors

    • @rob-blackbourn made his first contribution in https://github.com/dmlls/python-casefy/pull/1

    Full Changelog: https://github.com/dmlls/python-casefy/compare/v0.1.1...v0.1.2

    Source code(tar.gz)
    Source code(zip)
A small python library that helps you to generate localization strings for your mobile projects.

LocalizationUtiltiy A small python library that helps you to generate localization strings for your mobile projects. This small script aims to help yo

null 1 Nov 12, 2021
Python library to decorate and beautify strings

outputformat Python library to decorate and beautify your standard output ?? Ins

Felipe Delestro Matos 259 Dec 13, 2022
A way to write regex with objects instead of strings.

Py Idiomatic Regex (AKA iregex) Documentation Available Here An easier way to write regex in Python using OOP instead of strings. Makes the code much

Ryan Peach 18 Nov 15, 2021
A program to convert celcius to faranheit. made with python

Temp-Converter What is Temp-Converter Temp-Converter is little program made with pyhton to convert celcius to faranheit. Needed A python interpreter P

Chandula Janith 0 Nov 27, 2021
This two python programs can convert km to miles and miles to km

km-to-miles These two little python programs can convert kilometers to miles and miles to kilometers Needed Python3 or a online python compiler with t

Chandula Janith 3 Jan 30, 2022
Python lightweight dependency injection library

pythondi pythondi is a lightweight dependency injection library for python Support both sync and async functions Installation pip3 install pythondi Us

Hide 41 Dec 16, 2022
convert a dict-list object from / to a typed object(class instance with type annotation)

objtyping 带类型定义的对象转换器 由来 Python不是强类型语言,开发人员没有给数据定义类型的习惯。这样虽然灵活,但处理复杂业务逻辑的时候却不够方便——缺乏类型检查可能导致很难发现错误,在IDE里编码时也没

Song Hui 15 Dec 22, 2022
Convert any-bit number to decimal number and vise versa.

2deci Convert any-bit number to decimal number and vise versa. --bit n to set bit to n --exp xxx to set expression to xxx --r to run reversely (from d

null 3 Sep 15, 2021
A library to easily convert climbing route grades between different grading systems.

pyclimb A library to easily convert climbing route grades between different grading systems. In rock climbing, mountaineering, and other climbing disc

Ilias Antonopoulos 4 Jan 26, 2022
A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

A python package containing all the basic functions and classes for python. From simple addition to advanced file encryption.

PyBash 11 May 22, 2022