object-case-switcher


Nameobject-case-switcher JSON
Version 0.0.33 PyPI version JSON
download
home_pagehttps://github.com/Alex-Andr-19/case_switcher
SummaryThe easiest way to switch case of prop in return of your functions
upload_time2024-08-17 07:47:15
maintainerNone
docs_urlNone
authorAleksandrychev Andrey
requires_python>=3.6
licenseMIT License
keywords case switcher python snake camel switch
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CASE SWITCHER

This module provides a very **useful** feature that will simplify communication between developers of Python RestAPI and other API libraries and frontend developers.

The provided function (`transform_structure`) makes it possible to develop the main function code on the usual code case, but, called by default, it converts the fields of the object returned by the main function from `snake_case` to `camelCase`.

> It is better to install this library in your virtual environment

## Installing
```bash
pip install object_case_switcher
```

## Syntax
```python
@transform_structure()
async def load_data(*args, **kwargs):
    ...
```

## Parameters
- `case_type` - Type of transform rule (`snakeToCamel`, `camelToSnake`). Defaults to "snakeToCamel"  

- `transform_for` - Target of executon transform (return, argument). Defaults to "return"

- `arg_index` - Index of argument of target function. Defaults to **0**

- `arg_name` - Name of argument of target function. Defaults to **""**

- `_async` - Is synchronus or asynchronus target function . Defaults to `True`

## Examples
### Simple use
```python
from object_case_switcher import transform_structure

@transform_structure(_async=False)
def some_function():
    return {
        "some_property": 42,
    }

print(some_function())

# >>> '{"someProperty": 42}'
```

### Recursive case
You can return an object with any level of nesting from a function
```python
from object_case_switcher import transform_structure

@transform_structure(_async=False)
def some_function():
    return {
        "some_property": 42,
        "some_other_property": {
            "a": 52,
            "b": [
                {
                    "title_name": "John",
                },
                {
                    "title_name": "Dow",
                },
            ]
        },
    }

print(some_function())

```
Output
```json
{
    "someProperty": 42,
    "someOtherProperty": {
        "a": 52,
        "b": [
            {"titleName": "John"},
            {"titleName": "Dow"},
        ]
    }
}
```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Alex-Andr-19/case_switcher",
    "name": "object-case-switcher",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "case, switcher, python, snake, camel, switch",
    "author": "Aleksandrychev Andrey",
    "author_email": "aleks-andr-19@yandex.ru",
    "download_url": "https://files.pythonhosted.org/packages/9e/9a/a2093f46c67d83ae36900b27c389aa417403b39482eef72eeecfe3b26cb7/object_case_switcher-0.0.33.tar.gz",
    "platform": null,
    "description": "# CASE SWITCHER\n\nThis module provides a very **useful** feature that will simplify communication between developers of Python RestAPI and other API libraries and frontend developers.\n\nThe provided function (`transform_structure`) makes it possible to develop the main function code on the usual code case, but, called by default, it converts the fields of the object returned by the main function from `snake_case` to `camelCase`.\n\n> It is better to install this library in your virtual environment\n\n## Installing\n```bash\npip install object_case_switcher\n```\n\n## Syntax\n```python\n@transform_structure()\nasync def load_data(*args, **kwargs):\n    ...\n```\n\n## Parameters\n- `case_type` - Type of transform rule (`snakeToCamel`, `camelToSnake`). Defaults to \"snakeToCamel\"  \n\n- `transform_for` - Target of executon transform (return, argument). Defaults to \"return\"\n\n- `arg_index` - Index of argument of target function. Defaults to **0**\n\n- `arg_name` - Name of argument of target function. Defaults to **\"\"**\n\n- `_async` - Is synchronus or asynchronus target function . Defaults to `True`\n\n## Examples\n### Simple use\n```python\nfrom object_case_switcher import transform_structure\n\n@transform_structure(_async=False)\ndef some_function():\n    return {\n        \"some_property\": 42,\n    }\n\nprint(some_function())\n\n# >>> '{\"someProperty\": 42}'\n```\n\n### Recursive case\nYou can return an object with any level of nesting from a function\n```python\nfrom object_case_switcher import transform_structure\n\n@transform_structure(_async=False)\ndef some_function():\n    return {\n        \"some_property\": 42,\n        \"some_other_property\": {\n            \"a\": 52,\n            \"b\": [\n                {\n                    \"title_name\": \"John\",\n                },\n                {\n                    \"title_name\": \"Dow\",\n                },\n            ]\n        },\n    }\n\nprint(some_function())\n\n```\nOutput\n```json\n{\n    \"someProperty\": 42,\n    \"someOtherProperty\": {\n        \"a\": 52,\n        \"b\": [\n            {\"titleName\": \"John\"},\n            {\"titleName\": \"Dow\"},\n        ]\n    }\n}\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "The easiest way to switch case of prop in return of your functions",
    "version": "0.0.33",
    "project_urls": {
        "GitHub": "https://github.com/Alex-Andr-19/case_switcher",
        "Homepage": "https://github.com/Alex-Andr-19/case_switcher"
    },
    "split_keywords": [
        "case",
        " switcher",
        " python",
        " snake",
        " camel",
        " switch"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfcbc69f74d444771d43ebc2fa1b34f2c89f3f424220dd2d07f94641583b6e3f",
                "md5": "17ab1c8da2be4962b153c6d7c9643134",
                "sha256": "f2ba40172642adfe6611401992af471458102ed2e7a3217d4b0a250cad9621ea"
            },
            "downloads": -1,
            "filename": "object_case_switcher-0.0.33-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "17ab1c8da2be4962b153c6d7c9643134",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6521,
            "upload_time": "2024-08-17T07:47:13",
            "upload_time_iso_8601": "2024-08-17T07:47:13.714264Z",
            "url": "https://files.pythonhosted.org/packages/cf/cb/c69f74d444771d43ebc2fa1b34f2c89f3f424220dd2d07f94641583b6e3f/object_case_switcher-0.0.33-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e9aa2093f46c67d83ae36900b27c389aa417403b39482eef72eeecfe3b26cb7",
                "md5": "b68a6db29d47f184b19690c09e769b84",
                "sha256": "ff2129d412f61ae7d544d45048948b0eca69e68341dcfccd72ee5b7188319980"
            },
            "downloads": -1,
            "filename": "object_case_switcher-0.0.33.tar.gz",
            "has_sig": false,
            "md5_digest": "b68a6db29d47f184b19690c09e769b84",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 4558,
            "upload_time": "2024-08-17T07:47:15",
            "upload_time_iso_8601": "2024-08-17T07:47:15.312183Z",
            "url": "https://files.pythonhosted.org/packages/9e/9a/a2093f46c67d83ae36900b27c389aa417403b39482eef72eeecfe3b26cb7/object_case_switcher-0.0.33.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-17 07:47:15",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Alex-Andr-19",
    "github_project": "case_switcher",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "object-case-switcher"
}
        
Elapsed time: 0.30268s