An open API service indexing awesome lists of open source software.

https://github.com/zobweyt/textcase

A feature-rich Python text case conversion library
https://github.com/zobweyt/textcase

camel-case case constant-case conversion foss just kebab-case lower-case mypy nix pascal-case pypi pytest python ruff sentence-case snake-case text title-case upper-case

Last synced: about 1 month ago
JSON representation

A feature-rich Python text case conversion library

Awesome Lists containing this project

README

        



textcase logo


textcase


A feature-rich Python text case conversion library.



Coveralls


Dependencies


PyPI - Version


PyPI - Downloads


PyPI - Python Version


PyPI - Types


PyPI - Wheel


AUR Version

**Documentation**: https://zobweyt.github.io/textcase

**PyPI**: https://pypi.org/project/textcase

## Features

- **Text case conversion**: Convert strings between various text cases (e.g., snake_case, kebab-case, camelCase, etc.).
- **Extensible Design**: Easily extend the library with custom cases and boundaries.
- **Acronym Handling**: Properly detects and formats acronyms in strings (as in `HTTPRequest`).
- **Non-ASCII Support**: Handles non-ASCII characters seamlessly (no inferences on the input language itself is made).
- **100% Test Coverage**: Comprehensive tests ensure reliability and correctness.
- **Well-Documented**: Clean documentation with usage examples for easy understanding.
- **Performant**: Efficient implementation without the use of regular expressions.
- **Zero Dependencies**: The library has no external dependencies, making it lightweight and easy to integrate.

## Installation

Create and activate a virtual environment and then install [`textcase`](https://pypi.org/projects/textcase):

```sh
pip install textcase
```

## Usage

You can convert strings into a case using the [`convert`](https://zobweyt.github.io/textcase/reference/convert/) function:

```python
from textcase import case, convert

print(convert("ronnie james dio", case.SNAKE)) # ronnie_james_dio
print(convert("Ronnie_James_dio", case.CONSTANT)) # RONNIE_JAMES_DIO
print(convert("RONNIE_JAMES_DIO", case.KEBAB)) # ronnie-james-dio
print(convert("RONNIE-JAMES-DIO", case.CAMEL)) # ronnieJamesDio
print(convert("ronnie-james-dio", case.PASCAL)) # RonnieJamesDio
print(convert("RONNIE JAMES DIO", case.LOWER)) # ronnie james dio
print(convert("ronnie james dio", case.UPPER)) # RONNIE JAMES DIO
print(convert("ronnie-james-dio", case.TITLE)) # Ronnie James Dio
print(convert("ronnie james dio", case.SENTENCE)) # Ronnie james dio
```

See [documentation](https://zobweyt.github.io/textcase) for more usage examples.