Metadata-Version: 2.1
Name: caseutil
Version: 0.4.0
Summary: Naming case conventions parsing and converting tool.
Home-page: https://github.com/makukha/caseutil
License: MIT
Keywords: case,convert,naming,camel case,pascal case,snake case,kebab case,all caps,screaming snake case
Author: Michael Makukha
Author-email: m.makukha@gmail.com
Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development
Classifier: Topic :: Text Processing
Classifier: Topic :: Utilities
Classifier: Typing :: Typed
Project-URL: Repository, https://github.com/makukha/caseutil
Description-Content-Type: text/markdown

# caseutil
[![license](https://img.shields.io/github/license/makukha/caseutil.svg)](https://github.com/makukha/caseutil/blob/main/LICENSE)
[![Coverage Status](https://raw.githubusercontent.com/makukha/caseutil/0.4.0/docs/img/coverage-badge.svg)](https://github.com/makukha/caseutil)
[![pypi](https://img.shields.io/pypi/v/caseutil.svg)](https://pypi.python.org/pypi/caseutil)
[![versions](https://img.shields.io/pypi/pyversions/caseutil.svg)](https://pypi.org/project/caseutil)

**Naming case conventions parsing and converting tool.**

Small and clean, fully typed, zero dependency pure Python 2.7 to 3.13 and probably above.

The package supports detection and conversion between cases:

* snake_case
* camelCase
* PascalCase
* kebab-case
* ALL_CAPS_CASE (aka SCREAMING_SNAKE_CASE)
* Title Case

and more to be added.


## Usage

```doctest
>>> from caseutil import is_snake, to_snake

>>> text = 'Some-Title phrase'
>>> is_snake(text)
False
>>> to_snake(text)
'some_title_phrase'
```

### Command line tool

```bash
$ caseutil --case allcaps "hi there"
HI_THERE
$ echo "hi_there\nsee you" | python -m caseutil -c camel
hiThere
seeYou
```

### Supported cases

```doctest
>>> text = 'Some-Title phrase'
```

#### snake_case
```doctest
>>> from caseutil import is_snake, to_snake
>>> to_snake(text)
'some_title_phrase'
>>> is_snake(to_snake(text))
True
```

#### camelCase
```doctest
>>> from caseutil import is_camel, to_camel
>>> to_camel(text)
'someTitlePhrase'
>>> is_camel(to_camel(text))
True
```

#### PascalCase
```doctest
>>> from caseutil import is_pascal, to_pascal
>>> to_pascal(text)
'SomeTitlePhrase'
>>> is_pascal(to_pascal(text))
True
```

#### kebab-case
```doctest
>>> from caseutil import is_kebab, to_kebab
>>> to_kebab(text)
'some-title-phrase'
>>> is_kebab(to_kebab(text))
True
```

#### ALL_CAPS_CASE
```doctest
>>> from caseutil import is_allcaps, to_allcaps
>>> to_allcaps(text)
'SOME_TITLE_PHRASE'
>>> is_allcaps(to_allcaps(text))
True
```

#### Title Case
```doctest
>>> from caseutil import is_title, to_title
>>> to_title(text)
'Some Title Phrase'
>>> is_title(to_title(text))
True
```

### Separators

Phrase separators are non-word characters including underscore, and places where text case is changed from lower to upper. Digits are not treated as separators.

```doctest
>>> from caseutil import words
>>> words('!some_reallyMESsy text--wit4Digits.3VeryWh3re--')
'some,really,ME,Ssy,text,wit4,Digits,3Very,Wh3re'
```

### Unicode

Only ASCII names are supported. Unicode support is planned.


## Development

### Mac OS X

Requires Docker and Homebrew.

```bash
git clone https://github.com/makukha/caseutil.git
brew install go-task
task init
```

Testing:

```bash
task test
```

## Plans

* Add more test, explore edge cases
* Add Unicode support (write tests)
* Add more cases

