Convert between different types of cases (unicode supported)
This is a fork
All credit goes to Alejandro Frias - here is the original repo. I only forked to gain vendorized dependencies.
differences between my fork and the original
- I needed to remove the 'regex' dependency because it is not pure python and thus couldn't be vendorized.
- I removed python2 support. It might be trivial to add later but I don't plan on using python2 personally so if you want to use this fork and need support then create a github issue.
This is a port of the CaseConversion Sublime Plugin, 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 using the
regex package. Credit goes to Davis Clark's and the contributors to that plugin (Scott Bessler, Curtis Gibby, Matt Morrison) for their awesome work on making such a robust and awesome case converter.
- Autodetection of case (no need to specify explicitly which case you are converting from!)
- Unicode supported (non-ASCII characters for days!)
- Acronym detection (no funky splitting on every capital letter of an all caps acronym like
- And obviously case conversions from/to the following types of cases:
- Oh! Python2 and Python3 supported!
Normal use is self-explanatory.
>>> import case_conversion >>> case_conversion.kebabcase("FOO_BAR_STRING") 'foo-bar-string' >>> print(case_conversion.constcase(u"fóó-bar-string")) FÓÓ_BAR_STRING
To use acronym detection set
True and pass in a list of
acronyms to detect as whole words.
>>> import case_conversion >>> case_conversion.snakecase("fooBarHTTPError") 'foo_bar_h_t_t_p_error' # ewwww >>> case_conversion.snakecase("fooBarHTTPError", detect_acronyms=True, acronyms=['HTTP']) 'foo_bar_http_error' # pretty
pip install case-conversion
Using MIT licence with Davis Clark's Copyright
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size po_case_conversion-0.4.0-py3-none-any.whl (7.7 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size po_case_conversion-0.4.0.tar.gz (8.2 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for po_case_conversion-0.4.0-py3-none-any.whl