Skip to main content

change between one type of casing and another

Project description

Change Case

What is this for?

As simple as it is, I was surprised that there was no libraries in pypi that purely handled changing of casing from one style to another. Sure simple .title() is easy. But this library allows you to easily take any casing type and go from one to the other.

Types supported

Python Version Support

I only plan on supporting python 3, as that is what I primarily use. It works on python 3.3+. I have not tested on older versions.

Usage

Change Case is easy to use. You simply pass a string to get the new value. Example, if you want to convert a camelCasedString to a snake_cased_string, you would simply run:

old = "camelCasedString"
new = ChangeCase.camel_to_snake(old)
print(new)
# camel_cased_string

To see what is possibly, simply view the main file. You can run tests by running the file directly. You can also look at the tests to see the usage and response of each one.

Tests

You can easily run tests one of two ways. You can run the change_case.py file manually with python, and it will run the test.:

python3 change_case.py

or you can do this as well:

In [1]: from change_case import ChangeCase

In [2]: ChangeCase.run_tests()
camel_to_upper_camel tests passed.
camel_to_pascal tests passed.
camel_to_wiki tests passed.
camel_to_snake tests passed.
camel_to_param tests passed.
pascal_to_camel tests passed.
pascal_to_upper_camel tests passed.
pascal_to_wiki tests passed.
pascal_to_snake tests passed.
pascal_to_param tests passed.
wiki_to_camel tests passed.
wiki_to_upper_camel tests passed.
wiki_to_pascal tests passed.
wiki_to_snake tests passed.
wiki_to_param tests passed.
snake_to_camel tests passed.
snake_to_upper_camel tests passed.
snake_to_pascal tests passed.
snake_to_wiki tests passed.
snake_to_param tests passed.
param_to_camel tests passed.
param_to_upper_camel tests passed.
param_to_pascal tests passed.
param_to_wiki tests passed.
param_to_snake tests passed.

Contributing and Bugs

You can file any issues you find here:

https://github.com/SkiftCreative/python-change-case/issues

It is fairly simple to add new case types. Simply add the methods to ChangeCase and add the tests to ChangeCase.run_tests()

LICENSE

The MIT License (MIT)

Copyright (c) [2015] [Shawn McElroy]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

change_case-0.5.2.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file change_case-0.5.2.tar.gz.

File metadata

  • Download URL: change_case-0.5.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for change_case-0.5.2.tar.gz
Algorithm Hash digest
SHA256 6096ac5c888ec0baa1d5a1ba10e2a8e0e431a8fd586bb78f18f4a32eb1e063d9
MD5 92b6497ddf86279d5558a77d1fc57911
BLAKE2b-256 864f3d5dc5107163201db73f66bfd0d00fa5e3e32bb0d13ffab364f28138fad1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page