diff options
Diffstat (limited to 'python-strenum.spec')
| -rw-r--r-- | python-strenum.spec | 618 |
1 files changed, 618 insertions, 0 deletions
diff --git a/python-strenum.spec b/python-strenum.spec new file mode 100644 index 0000000..2aa2b2f --- /dev/null +++ b/python-strenum.spec @@ -0,0 +1,618 @@ +%global _empty_manifest_terminate_build 0 +Name: python-StrEnum +Version: 0.4.10 +Release: 1 +Summary: An Enum that inherits from str. +License: MIT License +URL: https://github.com/irgeek/StrEnum +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/ff/4a/a288cf630100b5f6dfaf4cf7b0eef5f166e0a53efbc0c1acfaf715dc042b/StrEnum-0.4.10.tar.gz +BuildArch: noarch + +Requires: python3-sphinx +Requires: python3-sphinx-rtd-theme +Requires: python3-myst-parser[linkify] +Requires: python3-twine +Requires: python3-pytest +Requires: python3-pytest-black +Requires: python3-pytest-cov +Requires: python3-pytest-pylint +Requires: python3-pylint + +%description +# StrEnum + +[](https://github.com/irgeek/StrEnum/actions) + +StrEnum is a Python `enum.Enum` that inherits from `str` to complement +`enum.IntEnum` in the standard library. Supports python 3.7+. + +## Installation + +You can use [pip](https://pip.pypa.io/en/stable/) to install. + +```bash +pip install StrEnum +``` + +## Usage + +```python +from enum import auto +from strenum import StrEnum + + +class HttpMethod(StrEnum): + GET = auto() + HEAD = auto() + POST = auto() + PUT = auto() + DELETE = auto() + CONNECT = auto() + OPTIONS = auto() + TRACE = auto() + PATCH = auto() + + +assert HttpMethod.GET == "GET" + +# You can use StrEnum values just like strings: + +import urllib.request + +req = urllib.request.Request('https://www.python.org/', method=HttpMethod.HEAD) +with urllib.request.urlopen(req) as response: + html = response.read() + +assert len(html) == 0 # HEAD requests do not (usually) include a body +``` + +There are classes whose `auto()` value folds each member name to upper or lower +case: + +```python +from enum import auto +from strenum import LowercaseStrEnum, UppercaseStrEnum + + +class Tag(LowercaseStrEnum): + Head = auto() + Body = auto() + Div = auto() + + +assert Tag.Head == "head" +assert Tag.Body == "body" +assert Tag.Div == "div" + + +class HttpMethod(UppercaseStrEnum): + Get = auto() + Head = auto() + Post = auto() + + +assert HttpMethod.Get == "GET" +assert HttpMethod.Head == "HEAD" +assert HttpMethod.Post == "POST" +``` + +As well as classes whose `auto()` value converts each member name to camelCase, +PascalCase, kebab-case, snake_case and MACRO_CASE: + +```python +from enum import auto +from strenum import CamelCaseStrEnum, PascalCaseStrEnum +from strenum import KebabCaseStrEnum, SnakeCaseStrEnum +from strenum import MacroCaseStrEnum + + +class CamelTestEnum(CamelCaseStrEnum): + OneTwoThree = auto() + + +class PascalTestEnum(PascalCaseStrEnum): + OneTwoThree = auto() + + +class KebabTestEnum(KebabCaseStrEnum): + OneTwoThree = auto() + + +class SnakeTestEnum(SnakeCaseStrEnum): + OneTwoThree = auto() + + +class MacroTestEnum(MacroCaseStrEnum): + OneTwoThree = auto() + + +assert CamelTestEnum.OneTwoThree == "oneTwoThree" +assert PascalTestEnum.OneTwoThree == "OneTwoThree" +assert KebabTestEnum.OneTwoThree == "one-two-three" +assert SnakeTestEnum.OneTwoThree == "one_two_three" +assert MacroTestEnum.OneTwoThree == "ONE_TWO_THREE" +``` + +As with any Enum you can, of course, manually assign values. + +```python +from strenum import StrEnum + + +class Shape(StrEnum): + CIRCLE = "Circle" + + +assert Shape.CIRCLE == "Circle" +``` + +Doing this with the case-changing classes, though, won't manipulate +values--whatever you assign is the value they end up with. + +```python +from strenum import KebabCaseStrEnum + + +class Shape(KebabCaseStrEnum): + CIRCLE = "Circle" + + +# This will raise an AssertionError because the value wasn't converted to kebab-case. +assert Shape.CIRCLE == "circle" +``` + +## Contributing + +Pull requests are welcome. For major changes, please open an issue first to +discuss what you would like to change. + +Please ensure tests pass before submitting a PR. This repository uses +[Black](https://black.readthedocs.io/en/stable/) and +[Pylint](https://www.pylint.org/) for consistency. Both are run automatically +as part of the test suite. + +## Running the tests + +Tests can be run using `make`: + +``` +make test +``` + +This will create a virutal environment, install the module and its test +dependencies and run the tests. Alternatively you can do the same thing +manually: + +``` +python3 -m venv .venv +.venv/bin/pip install .[test] +.venv/bin/pytest +``` + +## License + +[MIT](https://choosealicense.com/licenses/mit/) + +**N.B. Starting with Python 3.11, `enum.StrEnum` is available in the standard +library. This implementation is _not_ a drop-in replacement for the standard +library implementation. Specifically, the Python devs have decided to case fold +name to lowercase by default when `auto()` is used which I think violates the +principle of least surprise.** + + +%package -n python3-StrEnum +Summary: An Enum that inherits from str. +Provides: python-StrEnum +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-StrEnum +# StrEnum + +[](https://github.com/irgeek/StrEnum/actions) + +StrEnum is a Python `enum.Enum` that inherits from `str` to complement +`enum.IntEnum` in the standard library. Supports python 3.7+. + +## Installation + +You can use [pip](https://pip.pypa.io/en/stable/) to install. + +```bash +pip install StrEnum +``` + +## Usage + +```python +from enum import auto +from strenum import StrEnum + + +class HttpMethod(StrEnum): + GET = auto() + HEAD = auto() + POST = auto() + PUT = auto() + DELETE = auto() + CONNECT = auto() + OPTIONS = auto() + TRACE = auto() + PATCH = auto() + + +assert HttpMethod.GET == "GET" + +# You can use StrEnum values just like strings: + +import urllib.request + +req = urllib.request.Request('https://www.python.org/', method=HttpMethod.HEAD) +with urllib.request.urlopen(req) as response: + html = response.read() + +assert len(html) == 0 # HEAD requests do not (usually) include a body +``` + +There are classes whose `auto()` value folds each member name to upper or lower +case: + +```python +from enum import auto +from strenum import LowercaseStrEnum, UppercaseStrEnum + + +class Tag(LowercaseStrEnum): + Head = auto() + Body = auto() + Div = auto() + + +assert Tag.Head == "head" +assert Tag.Body == "body" +assert Tag.Div == "div" + + +class HttpMethod(UppercaseStrEnum): + Get = auto() + Head = auto() + Post = auto() + + +assert HttpMethod.Get == "GET" +assert HttpMethod.Head == "HEAD" +assert HttpMethod.Post == "POST" +``` + +As well as classes whose `auto()` value converts each member name to camelCase, +PascalCase, kebab-case, snake_case and MACRO_CASE: + +```python +from enum import auto +from strenum import CamelCaseStrEnum, PascalCaseStrEnum +from strenum import KebabCaseStrEnum, SnakeCaseStrEnum +from strenum import MacroCaseStrEnum + + +class CamelTestEnum(CamelCaseStrEnum): + OneTwoThree = auto() + + +class PascalTestEnum(PascalCaseStrEnum): + OneTwoThree = auto() + + +class KebabTestEnum(KebabCaseStrEnum): + OneTwoThree = auto() + + +class SnakeTestEnum(SnakeCaseStrEnum): + OneTwoThree = auto() + + +class MacroTestEnum(MacroCaseStrEnum): + OneTwoThree = auto() + + +assert CamelTestEnum.OneTwoThree == "oneTwoThree" +assert PascalTestEnum.OneTwoThree == "OneTwoThree" +assert KebabTestEnum.OneTwoThree == "one-two-three" +assert SnakeTestEnum.OneTwoThree == "one_two_three" +assert MacroTestEnum.OneTwoThree == "ONE_TWO_THREE" +``` + +As with any Enum you can, of course, manually assign values. + +```python +from strenum import StrEnum + + +class Shape(StrEnum): + CIRCLE = "Circle" + + +assert Shape.CIRCLE == "Circle" +``` + +Doing this with the case-changing classes, though, won't manipulate +values--whatever you assign is the value they end up with. + +```python +from strenum import KebabCaseStrEnum + + +class Shape(KebabCaseStrEnum): + CIRCLE = "Circle" + + +# This will raise an AssertionError because the value wasn't converted to kebab-case. +assert Shape.CIRCLE == "circle" +``` + +## Contributing + +Pull requests are welcome. For major changes, please open an issue first to +discuss what you would like to change. + +Please ensure tests pass before submitting a PR. This repository uses +[Black](https://black.readthedocs.io/en/stable/) and +[Pylint](https://www.pylint.org/) for consistency. Both are run automatically +as part of the test suite. + +## Running the tests + +Tests can be run using `make`: + +``` +make test +``` + +This will create a virutal environment, install the module and its test +dependencies and run the tests. Alternatively you can do the same thing +manually: + +``` +python3 -m venv .venv +.venv/bin/pip install .[test] +.venv/bin/pytest +``` + +## License + +[MIT](https://choosealicense.com/licenses/mit/) + +**N.B. Starting with Python 3.11, `enum.StrEnum` is available in the standard +library. This implementation is _not_ a drop-in replacement for the standard +library implementation. Specifically, the Python devs have decided to case fold +name to lowercase by default when `auto()` is used which I think violates the +principle of least surprise.** + + +%package help +Summary: Development documents and examples for StrEnum +Provides: python3-StrEnum-doc +%description help +# StrEnum + +[](https://github.com/irgeek/StrEnum/actions) + +StrEnum is a Python `enum.Enum` that inherits from `str` to complement +`enum.IntEnum` in the standard library. Supports python 3.7+. + +## Installation + +You can use [pip](https://pip.pypa.io/en/stable/) to install. + +```bash +pip install StrEnum +``` + +## Usage + +```python +from enum import auto +from strenum import StrEnum + + +class HttpMethod(StrEnum): + GET = auto() + HEAD = auto() + POST = auto() + PUT = auto() + DELETE = auto() + CONNECT = auto() + OPTIONS = auto() + TRACE = auto() + PATCH = auto() + + +assert HttpMethod.GET == "GET" + +# You can use StrEnum values just like strings: + +import urllib.request + +req = urllib.request.Request('https://www.python.org/', method=HttpMethod.HEAD) +with urllib.request.urlopen(req) as response: + html = response.read() + +assert len(html) == 0 # HEAD requests do not (usually) include a body +``` + +There are classes whose `auto()` value folds each member name to upper or lower +case: + +```python +from enum import auto +from strenum import LowercaseStrEnum, UppercaseStrEnum + + +class Tag(LowercaseStrEnum): + Head = auto() + Body = auto() + Div = auto() + + +assert Tag.Head == "head" +assert Tag.Body == "body" +assert Tag.Div == "div" + + +class HttpMethod(UppercaseStrEnum): + Get = auto() + Head = auto() + Post = auto() + + +assert HttpMethod.Get == "GET" +assert HttpMethod.Head == "HEAD" +assert HttpMethod.Post == "POST" +``` + +As well as classes whose `auto()` value converts each member name to camelCase, +PascalCase, kebab-case, snake_case and MACRO_CASE: + +```python +from enum import auto +from strenum import CamelCaseStrEnum, PascalCaseStrEnum +from strenum import KebabCaseStrEnum, SnakeCaseStrEnum +from strenum import MacroCaseStrEnum + + +class CamelTestEnum(CamelCaseStrEnum): + OneTwoThree = auto() + + +class PascalTestEnum(PascalCaseStrEnum): + OneTwoThree = auto() + + +class KebabTestEnum(KebabCaseStrEnum): + OneTwoThree = auto() + + +class SnakeTestEnum(SnakeCaseStrEnum): + OneTwoThree = auto() + + +class MacroTestEnum(MacroCaseStrEnum): + OneTwoThree = auto() + + +assert CamelTestEnum.OneTwoThree == "oneTwoThree" +assert PascalTestEnum.OneTwoThree == "OneTwoThree" +assert KebabTestEnum.OneTwoThree == "one-two-three" +assert SnakeTestEnum.OneTwoThree == "one_two_three" +assert MacroTestEnum.OneTwoThree == "ONE_TWO_THREE" +``` + +As with any Enum you can, of course, manually assign values. + +```python +from strenum import StrEnum + + +class Shape(StrEnum): + CIRCLE = "Circle" + + +assert Shape.CIRCLE == "Circle" +``` + +Doing this with the case-changing classes, though, won't manipulate +values--whatever you assign is the value they end up with. + +```python +from strenum import KebabCaseStrEnum + + +class Shape(KebabCaseStrEnum): + CIRCLE = "Circle" + + +# This will raise an AssertionError because the value wasn't converted to kebab-case. +assert Shape.CIRCLE == "circle" +``` + +## Contributing + +Pull requests are welcome. For major changes, please open an issue first to +discuss what you would like to change. + +Please ensure tests pass before submitting a PR. This repository uses +[Black](https://black.readthedocs.io/en/stable/) and +[Pylint](https://www.pylint.org/) for consistency. Both are run automatically +as part of the test suite. + +## Running the tests + +Tests can be run using `make`: + +``` +make test +``` + +This will create a virutal environment, install the module and its test +dependencies and run the tests. Alternatively you can do the same thing +manually: + +``` +python3 -m venv .venv +.venv/bin/pip install .[test] +.venv/bin/pytest +``` + +## License + +[MIT](https://choosealicense.com/licenses/mit/) + +**N.B. Starting with Python 3.11, `enum.StrEnum` is available in the standard +library. This implementation is _not_ a drop-in replacement for the standard +library implementation. Specifically, the Python devs have decided to case fold +name to lowercase by default when `auto()` is used which I think violates the +principle of least surprise.** + + +%prep +%autosetup -n StrEnum-0.4.10 + +%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-StrEnum -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 0.4.10-1 +- Package Spec generated |
