Home

Awesome

Case Conversion

This is a port of the Sublime Text 3 plugin CaseConversion, by Davis Clark's, to a regular python package. I couldn't find any other python packages on PyPI at the time (Feb 2016) that could seamlessly convert from any case to any other case without having to specify from what type of case I was converting. This plugin worked really well, so I separated the (non-sublime) python parts of the plugin into this useful python package. I also added Unicode support via python's unicodedata.

Features

Usage

Normal use is self-explanatory.

>>> import case_conversion
>>> case_conversion.dash("FOO_BAR_STRING")
'foo-bar-string'

To use acronym detection simply pass in a list of acronyms to detect as whole words.

>>> import case_conversion
>>> case_conversion.snake("fooBarHTTPError")
'foo_bar_h_t_t_p_error'  # ewwww :(
>>> case_conversion.snake("fooBarHTTPError", acronyms=['HTTP'])
'foo_bar_http_error'  # pretty :)

Unicode is fully supported - even for acronyms.

>>> import case_conversion
>>> case_conversion.const(u"fóó-bar-string")
FÓÓ_BAR_STRING
>>> case_conversion.snake("fooBarHÓÓPError", acronyms=['HÓÓP'])
'foo_bar_hóóp_error'

Install

pip install case-conversion

Contribute

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

This package is being developed with poetry (-> docs).

Before opening a pull request, please make sure to:

Credits

Credit goes to Davis Clark's as the author of the original plugin and its contributors (Scott Bessler, Curtis Gibby, Matt Morrison). Thanks for their awesome work on making such a robust and awesome case converter.

Further credit goes to @olsonpm for making this package dependency-free.

Licence

Using MIT licence with Davis Clark's Copyright