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.
Raw data
{
"_id": null,
"home_page": "https://github.com/preduus/pycasestyle",
"name": "pycasestyle",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": "",
"keywords": "pycasestyle,camelcase,snakecase,pascal case,kebab case,dict key case,string case",
"author": "Pedro Rodrigues",
"author_email": "pedrota.rodrigues@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/d8/d9/b9cf35bcb04331171ca26f97546a6869ae8ec4fb70d397c9ee196122ca14/pycasestyle-0.1.4.tar.gz",
"platform": null,
"description": "pycasestyle\n===========\n\npycasestyle is a Python library for converting variable naming styles between CamelCase, snake_case, kebab-case, and PascalCase.\n\nSupported styles:\n - CamelCase\n - SnakeCase\n - KebabCase\n - PascalCase\n\nInstallation\n------------\n\nTo install pycasestyle, you can use pip:\n\n.. code-block:: bash\n pip install pycasestyle\n\nUsage\n-----\n\nYou 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:\n\n.. code-block:: python\n import pycasestyle\n\n # Converting to camelcase from text\n camelcased_text = pycasestyle.camelcase.from_string(\"i want a camel\")\n print(camelcased_text) # Output: \"iWantACamel\"\n\n # Converting to camelcase from dict\n camelcased_dict = pycasestyle.camelcase.from_dict({\"i want a camel\": \"value\"})\n print(camelcased_dict) # Output: {\"iWantACamel\": \"value\"}\n\n # Converting to snakecase from text\n snakecased_text = pycasestyle.snakecase.from_string(\"I Want A Snake\")\n print(snakecased_text) # Output: \"i_want_a_snake\"\n\n # Converting to snakecase from dict\n snakecased_dict = pycasestyle.snakecase.from_dict({\"I Want A Snake\": \"value\"})\n print(snakecased_dict) # Output: {\"i_want_a_snake\": \"value\"}\n\n # Converting to kebab-case\n kebabcased_text = pycasestyle.kebabcase.from_string(\"I Want A Kebab\")\n print(kebabcased_text) # Output: \"i-want-a-kebab\"\n\n # Converting to kebab-case from dict\n kebabcased_dict = pycasestyle.kebabcase.from_dict({\"I Want A Kebab\": \"value\"})\n print(kebabcased_dict) # Output: {\"i-want-a-kebab\": \"value\"}\n\n # Converting to PascalCase from text\n pascalcased_text = pycasestyle.pascalcase.from_string(\"i want a pascal\")\n print(pascalcased_text) # Output: \"IWantAPascal\"\n\n # Converting to PascalCase from dict\n pascalcased_dict = pycasestyle.pascalcase.from_dict({\"i want a pascal\": \"value\"})\n print(pascalcased_dict) # Output: {\"IWantAPascal\": \"value\"}\nUse cases\n------------\nIf you needed convert schemas, mappings, contracts, etc. This tool is specific to turn easily your job.\n\nReal use case:\n\nYou 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:\n\n\n.. code-block:: python\n import pycasestyle\n\n postgres_contract = {\n \"id\": 1,\n \"customers_id\": 32,\n \"users_id\": 56,\n \"period_datetime\": \"2024-08-10\"\n }\n\n elastic_contract = pycasestyle.camelcase.from_dict(postgres_contract)\n print(elastic_contract) # Output: {\n \"id\": 1,\n \"customersId\": 32,\n \"usersId\": 56,\n \"periodDatetime\": \"2024-08-10\"\n }\n\nContributing\n------------\n\nIf 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>`.\n\nLicense\n-------\n\nThis project is licensed under the Apache License 2.0 License. See the `LICENSE <https://github.com/preduus/pycasestyle/LICENSE>` file for more details.\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "A simple python lib to convert string and dict keys to camelcase, pascal case, kebab case and snake case.",
"version": "0.1.4",
"project_urls": {
"Homepage": "https://github.com/preduus/pycasestyle"
},
"split_keywords": [
"pycasestyle",
"camelcase",
"snakecase",
"pascal case",
"kebab case",
"dict key case",
"string case"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a39d5f23fa984c4973dfb6e6e58d618f901160a75b082b890220014835306870",
"md5": "7ed300c54017bb900012e0097f597851",
"sha256": "b8723f1dae2667e21d8f4a0eedb1c82e549caedf95388b10b4b5a69c44019e22"
},
"downloads": -1,
"filename": "pycasestyle-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7ed300c54017bb900012e0097f597851",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 10573,
"upload_time": "2024-02-14T01:00:25",
"upload_time_iso_8601": "2024-02-14T01:00:25.118982Z",
"url": "https://files.pythonhosted.org/packages/a3/9d/5f23fa984c4973dfb6e6e58d618f901160a75b082b890220014835306870/pycasestyle-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d8d9b9cf35bcb04331171ca26f97546a6869ae8ec4fb70d397c9ee196122ca14",
"md5": "0ae16c8fccb447e4e050493c00d987fe",
"sha256": "0d3a8443d53ba0f8ed31ef26350da590f190adf1c3e363f7492d485dfb0afee1"
},
"downloads": -1,
"filename": "pycasestyle-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "0ae16c8fccb447e4e050493c00d987fe",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 10119,
"upload_time": "2024-02-14T01:00:26",
"upload_time_iso_8601": "2024-02-14T01:00:26.740810Z",
"url": "https://files.pythonhosted.org/packages/d8/d9/b9cf35bcb04331171ca26f97546a6869ae8ec4fb70d397c9ee196122ca14/pycasestyle-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-14 01:00:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "preduus",
"github_project": "pycasestyle",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pycasestyle"
}