Code Monkey home page Code Monkey logo

case-conversion's Introduction

Case Conversion

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 seemlessly convert from any case to any other case without having to specifiy 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 suport using the regex package. Credit goes to Davis Clark's and the contributers to that plugin (Scott Bessler, Curtis Gibby, Matt Morrison) for their awesome work on making such a robust and awesome case converter.

Features

  • 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 HTTPError!)
  • And obviously case conversions from/to the following types of cases:
    • camelcase
    • pascalcase
    • snakecase
    • dashcase
    • spinalcase (alias for dashcase)
    • kebabcase (alias for dashcase)
    • constcase
    • dotcase
    • separate_words
    • slashcase
    • backslashcase
  • Oh! Python2 and Python3 supported!
Usage

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 detect_acronyms to True and pass in a list of acronyms to detect as whole words.

>>> import case_conversion
>>> case_conversion.snakecase("fooBarHTTPError", detect_acronyms=True, acronyms=['HTTP'])
'foo_bar_http_error'

Install

pip install case-conversion

Licence

Using MIT licence with Davis Clark's Copyright

case-conversion's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.