diff options
author | CoprDistGit <infra@openeuler.org> | 2023-06-20 05:47:09 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-06-20 05:47:09 +0000 |
commit | 5d5c70c587b4f11267f3b0e5904809909ffd338b (patch) | |
tree | 2de5cf295364127f1e9656c62a90e774f909ad3d | |
parent | 1629b299c460dd0add1b1fd80f7747a90f020b3d (diff) |
automatic import of python-camel-converteropeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-camel-converter.spec | 529 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 531 insertions, 0 deletions
@@ -0,0 +1 @@ +/camel_converter-3.0.0.tar.gz diff --git a/python-camel-converter.spec b/python-camel-converter.spec new file mode 100644 index 0000000..078cc94 --- /dev/null +++ b/python-camel-converter.spec @@ -0,0 +1,529 @@ +%global _empty_manifest_terminate_build 0 +Name: python-camel-converter +Version: 3.0.0 +Release: 1 +Summary: Converts a string from snake case to camel case or camel case to snake case +License: MIT +URL: https://github.com/sanders41/camel-converter +Source0: https://mirrors.aliyun.com/pypi/web/packages/67/74/92806bf240c3e2ce6cdddce5b7661f33d1bcc45f8d38dc3a1b2633e04134/camel_converter-3.0.0.tar.gz +BuildArch: noarch + +Requires: python3-pydantic + +%description +# Camel Converter + +[](https://github.com/sanders41/camel-converter/actions?query=workflow%3CI+branch%3Amain+event%3Apush) +[](https://results.pre-commit.ci/latest/github/sanders41/camel-converter/main) +[](https://codecov.io/gh/sanders41/camel-converter) +[](https://badge.fury.io/py/camel-converter) +[](https://github.com/sanders41/camel-converter) + +In JSON keys are frequently in camelCase format, while variable names in Python are typically +snake_case. The purpose of this pacakgae is to help convert between the two formats. + +## Usage + +- To convert from camel case to snake case: + + ```py + from camel_converter import to_snake + + snake = to_snake("myString") + ``` + + This will convert `myString` into `my_string` + +- To convert a dictonary's keys from camel case to snake case: + + ```py + from camel_converter import dict_to_snake + + snake = dict_to_snake({"myString": "val 1"}) + ``` + + This will convert `{"myString": "val 1"}` into `{"my_string": "val 1"}`. Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_snake + + @dict_to_snake + def my_func() -> dict[str, str]: + return {"myString": "val 1"} + + snake = my_func() + ``` + + `my_func` will return `{"my_string": "val 1"}`. Non-string keys will be + left unchanged. + +- To convert from snake case to camel case: + + ```py + from camel_converter import to_camel + + camel = to_camel("my_string") + ``` + + This will convert `my_string` into `myString` + +- To convert from a dictionary's keys from snake case to camel case: + + ```py + from camel_converter import dict_to_camel + + camel = to_camel({"my_string": "val 1"}) + ``` + + This will convert `{"my_string": "val 1"}` into `{"myString": "val 1"}` Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_camel + + @dict_to_camel + def my_func() -> dict[str, str]: + return {"my_string": "val 1"} + + camel = my_func() + ``` + + `my_func` will return `{"myString": "val 1"}`. Non-string keys will be + left unchanged. + +- To convert from snake to pascal case: + + ```py + from camel_converter import to_pascal + + pascal = to_pascal("my_string") + ``` + + This will convert `my_string` into `MyString` + +- To convert from a dictionary's keys from snake case to pascal case: + + ```py + from camel_converter import dict_to_pascal + + pascal = to_pascal({"my_string": "val 1"}) + ``` + + This will convert `{"my_string": "val 1"}` into `{"MyString": "val 1"}` Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_pascal + + @dict_to_pascal + def my_func() -> dict[str, str]: + return {"my_string": "val 1"} + + pascal = my_func() + ``` + + `my_func` will return `{"MyString": "val 1"}`. Non-string keys will be + left unchanged. + +### Optional Extras + +An optional extra is provided for [Pydantic](https://pydantic-docs.helpmanual.io/) that provides a +base class to automatically convert between snake case and camel case. To use this Pydantic class +install camel converter with: + +```sh +pip install camel-converter[pydantic] +``` + +Then your Pydantic classes can inherit from CamelBase. + +```py +from camel_converter.pydantic_base import CamelBase + + +class MyModel(CamelBase): + test_field: str + + +my_data = MyModel(**{"testField": "my value"}) +print(my_data.test_field) +``` + +will result in `my value` being printed. + +With setting up your model in this way `myField` from the source, i.e. JSON data, will map to `my_field` in your model. + +## Contributing + +If you are interesting in contributing to this project please see our [contributing guide](CONTRIBUTING.md) + + +%package -n python3-camel-converter +Summary: Converts a string from snake case to camel case or camel case to snake case +Provides: python-camel-converter +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-camel-converter +# Camel Converter + +[](https://github.com/sanders41/camel-converter/actions?query=workflow%3CI+branch%3Amain+event%3Apush) +[](https://results.pre-commit.ci/latest/github/sanders41/camel-converter/main) +[](https://codecov.io/gh/sanders41/camel-converter) +[](https://badge.fury.io/py/camel-converter) +[](https://github.com/sanders41/camel-converter) + +In JSON keys are frequently in camelCase format, while variable names in Python are typically +snake_case. The purpose of this pacakgae is to help convert between the two formats. + +## Usage + +- To convert from camel case to snake case: + + ```py + from camel_converter import to_snake + + snake = to_snake("myString") + ``` + + This will convert `myString` into `my_string` + +- To convert a dictonary's keys from camel case to snake case: + + ```py + from camel_converter import dict_to_snake + + snake = dict_to_snake({"myString": "val 1"}) + ``` + + This will convert `{"myString": "val 1"}` into `{"my_string": "val 1"}`. Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_snake + + @dict_to_snake + def my_func() -> dict[str, str]: + return {"myString": "val 1"} + + snake = my_func() + ``` + + `my_func` will return `{"my_string": "val 1"}`. Non-string keys will be + left unchanged. + +- To convert from snake case to camel case: + + ```py + from camel_converter import to_camel + + camel = to_camel("my_string") + ``` + + This will convert `my_string` into `myString` + +- To convert from a dictionary's keys from snake case to camel case: + + ```py + from camel_converter import dict_to_camel + + camel = to_camel({"my_string": "val 1"}) + ``` + + This will convert `{"my_string": "val 1"}` into `{"myString": "val 1"}` Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_camel + + @dict_to_camel + def my_func() -> dict[str, str]: + return {"my_string": "val 1"} + + camel = my_func() + ``` + + `my_func` will return `{"myString": "val 1"}`. Non-string keys will be + left unchanged. + +- To convert from snake to pascal case: + + ```py + from camel_converter import to_pascal + + pascal = to_pascal("my_string") + ``` + + This will convert `my_string` into `MyString` + +- To convert from a dictionary's keys from snake case to pascal case: + + ```py + from camel_converter import dict_to_pascal + + pascal = to_pascal({"my_string": "val 1"}) + ``` + + This will convert `{"my_string": "val 1"}` into `{"MyString": "val 1"}` Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_pascal + + @dict_to_pascal + def my_func() -> dict[str, str]: + return {"my_string": "val 1"} + + pascal = my_func() + ``` + + `my_func` will return `{"MyString": "val 1"}`. Non-string keys will be + left unchanged. + +### Optional Extras + +An optional extra is provided for [Pydantic](https://pydantic-docs.helpmanual.io/) that provides a +base class to automatically convert between snake case and camel case. To use this Pydantic class +install camel converter with: + +```sh +pip install camel-converter[pydantic] +``` + +Then your Pydantic classes can inherit from CamelBase. + +```py +from camel_converter.pydantic_base import CamelBase + + +class MyModel(CamelBase): + test_field: str + + +my_data = MyModel(**{"testField": "my value"}) +print(my_data.test_field) +``` + +will result in `my value` being printed. + +With setting up your model in this way `myField` from the source, i.e. JSON data, will map to `my_field` in your model. + +## Contributing + +If you are interesting in contributing to this project please see our [contributing guide](CONTRIBUTING.md) + + +%package help +Summary: Development documents and examples for camel-converter +Provides: python3-camel-converter-doc +%description help +# Camel Converter + +[](https://github.com/sanders41/camel-converter/actions?query=workflow%3CI+branch%3Amain+event%3Apush) +[](https://results.pre-commit.ci/latest/github/sanders41/camel-converter/main) +[](https://codecov.io/gh/sanders41/camel-converter) +[](https://badge.fury.io/py/camel-converter) +[](https://github.com/sanders41/camel-converter) + +In JSON keys are frequently in camelCase format, while variable names in Python are typically +snake_case. The purpose of this pacakgae is to help convert between the two formats. + +## Usage + +- To convert from camel case to snake case: + + ```py + from camel_converter import to_snake + + snake = to_snake("myString") + ``` + + This will convert `myString` into `my_string` + +- To convert a dictonary's keys from camel case to snake case: + + ```py + from camel_converter import dict_to_snake + + snake = dict_to_snake({"myString": "val 1"}) + ``` + + This will convert `{"myString": "val 1"}` into `{"my_string": "val 1"}`. Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_snake + + @dict_to_snake + def my_func() -> dict[str, str]: + return {"myString": "val 1"} + + snake = my_func() + ``` + + `my_func` will return `{"my_string": "val 1"}`. Non-string keys will be + left unchanged. + +- To convert from snake case to camel case: + + ```py + from camel_converter import to_camel + + camel = to_camel("my_string") + ``` + + This will convert `my_string` into `myString` + +- To convert from a dictionary's keys from snake case to camel case: + + ```py + from camel_converter import dict_to_camel + + camel = to_camel({"my_string": "val 1"}) + ``` + + This will convert `{"my_string": "val 1"}` into `{"myString": "val 1"}` Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_camel + + @dict_to_camel + def my_func() -> dict[str, str]: + return {"my_string": "val 1"} + + camel = my_func() + ``` + + `my_func` will return `{"myString": "val 1"}`. Non-string keys will be + left unchanged. + +- To convert from snake to pascal case: + + ```py + from camel_converter import to_pascal + + pascal = to_pascal("my_string") + ``` + + This will convert `my_string` into `MyString` + +- To convert from a dictionary's keys from snake case to pascal case: + + ```py + from camel_converter import dict_to_pascal + + pascal = to_pascal({"my_string": "val 1"}) + ``` + + This will convert `{"my_string": "val 1"}` into `{"MyString": "val 1"}` Non-string keys will be + left unchanged. + + This is also available as a decorator for functions that return a dictionary. + + ```py + from camel_converter.decorators import dict_to_pascal + + @dict_to_pascal + def my_func() -> dict[str, str]: + return {"my_string": "val 1"} + + pascal = my_func() + ``` + + `my_func` will return `{"MyString": "val 1"}`. Non-string keys will be + left unchanged. + +### Optional Extras + +An optional extra is provided for [Pydantic](https://pydantic-docs.helpmanual.io/) that provides a +base class to automatically convert between snake case and camel case. To use this Pydantic class +install camel converter with: + +```sh +pip install camel-converter[pydantic] +``` + +Then your Pydantic classes can inherit from CamelBase. + +```py +from camel_converter.pydantic_base import CamelBase + + +class MyModel(CamelBase): + test_field: str + + +my_data = MyModel(**{"testField": "my value"}) +print(my_data.test_field) +``` + +will result in `my value` being printed. + +With setting up your model in this way `myField` from the source, i.e. JSON data, will map to `my_field` in your model. + +## Contributing + +If you are interesting in contributing to this project please see our [contributing guide](CONTRIBUTING.md) + + +%prep +%autosetup -n camel_converter-3.0.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-camel-converter -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 3.0.0-1 +- Package Spec generated @@ -0,0 +1 @@ +4eb0a2a97d4cd65f32a676a8e5459cca camel_converter-3.0.0.tar.gz |