Skip to main content

pycasestyle

pycasestyle is a Python library for converting variable naming styles between CamelCase, snake_case, kebab-case, and PascalCase.

Supported styles: - CamelCase - SnakeCase - KebabCase - PascalCase

Installation

To install pycasestyle, you can use pip:

.. code-block:: bash pip install pycasestyle

Usage

You can import the text formatting styles directly from the pycasestyle module and use them in your code. Here's an example of how to use the text formatting styles:

.. code-block:: python import pycasestyle

# Converting to camelcase from text
camelcased_text = pycasestyle.camelcase.from_string("i want a camel")
print(camelcased_text)  # Output: "iWantACamel"

# Converting to camelcase from dict
camelcased_dict = pycasestyle.camelcase.from_dict({"i want a camel": "value"})
print(camelcased_dict)  # Output: {"iWantACamel": "value"}

# Converting to snakecase from text
snakecased_text = pycasestyle.snakecase.from_string("I Want A Snake")
print(snakecased_text)  # Output: "i_want_a_snake"

# Converting to snakecase from dict
snakecased_dict = pycasestyle.snakecase.from_dict({"I Want A Snake": "value"})
print(snakecased_dict)  # Output: {"i_want_a_snake": "value"}

# Converting to kebab-case
kebabcased_text = pycasestyle.kebabcase.from_string("I Want A Kebab")
print(kebabcased_text)  # Output: "i-want-a-kebab"

# Converting to kebab-case from dict
kebabcased_dict = pycasestyle.kebabcase.from_dict({"I Want A Kebab": "value"})
print(kebabcased_dict)  # Output: {"i-want-a-kebab": "value"}

# Converting to PascalCase from text
pascalcased_text = pycasestyle.pascalcase.from_string("i want a pascal")
print(pascalcased_text)  # Output: "IWantAPascal"

# Converting to PascalCase from dict
pascalcased_dict = pycasestyle.pascalcase.from_dict({"i want a pascal": "value"})
print(pascalcased_dict)  # Output: {"IWantAPascal": "value"}

Use cases

If you needed convert schemas, mappings, contracts, etc. This tool is specific to turn easily your job.

Real use case:

You need to migrate information from Postgres to Elasticsearch, however, the mapping used in Elastic is following the camelcase pattern, whereas in Postgres it is with the Snakecase pattern, see how simple it is to solve:

.. code-block:: python import pycasestyle

postgres_contract = {
    "id": 1,
    "customers_id": 32,
    "users_id": 56,
    "period_datetime": "2024-08-10"
}

elastic_contract = pycasestyle.camelcase.from_dict(postgres_contract)
print(elastic_contract) # Output: {
    "id": 1,
    "customersId": 32,
    "usersId": 56,
    "periodDatetime": "2024-08-10"
}

Contributing

If you encounter any issues or have suggestions for improvement, feel free to open an issue or submit a pull request on the GitHub repository <https://github.com/preduus/pycasestyle>.

License

This project is licensed under the Apache License 2.0 License. See the LICENSE <https://github.com/preduus/pycasestyle/LICENSE> file for more details.

Metadata

Release files for pycasestyle 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pycasestyle 0.1.4
File Size Uploaded Provenance Actions
pycasestyle-0.1.4.tar.gz 10.1 kB Without provenance Details for pycasestyle-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pycasestyle 0.1.4
File Interpreter ABI Platform Actions
pycasestyle-0.1.4-py3-none-any.whl Python 3 none any Details for pycasestyle-0.1.4-py3-none-any.whl

Total release size: 20.7 kB

Release files / pycasestyle-0.1.4.tar.gz

Download URL pycasestyle-0.1.4.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0d3a8443d53ba0f8ed31ef26350da590f190adf1c3e363f7492d485dfb0afee1
BLAKE2b-256 checksum
How to use checksums
d8d9b9cf35bcb04331171ca26f97546a6869ae8ec4fb70d397c9ee196122ca14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / pycasestyle-0.1.4-py3-none-any.whl

Download URL pycasestyle-0.1.4-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8723f1dae2667e21d8f4a0eedb1c82e549caedf95388b10b4b5a69c44019e22
BLAKE2b-256 checksum
How to use checksums
a39d5f23fa984c4973dfb6e6e58d618f901160a75b082b890220014835306870
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for pycasestyle 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page