diff options
Diffstat (limited to 'python-option.spec')
| -rw-r--r-- | python-option.spec | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/python-option.spec b/python-option.spec new file mode 100644 index 0000000..48a6001 --- /dev/null +++ b/python-option.spec @@ -0,0 +1,208 @@ +%global _empty_manifest_terminate_build 0 +Name: python-option +Version: 2.1.0 +Release: 1 +Summary: Rust like Option and Result types in Python +License: MIT +URL: https://mat1g3r.github.io/option/ +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/15/7a/3622379bd82f70a0b88779566c4847f167ae54103187922b69ad63d3c3b2/option-2.1.0.tar.gz +BuildArch: noarch + +Requires: python3-typing-extensions + +%description +# Option +[](https://circleci.com/gh/MaT1g3R/option/tree/master) + +Rust-like [Option](https://doc.rust-lang.org/std/option/enum.Option.html) and [Result](https://doc.rust-lang.org/std/result/enum.Result.html) types in Python, slotted and fully typed. + +An `Option` type represents an optional value, every `Option` is either `Some` and contains Some value, or `NONE` + +A `Result` type represents a value that might be an error. Every `Result` is either `Ok` and contains a success value, or `Err` and contains an error value. + +Using an `Option` type forces you to deal with `None` values in your code and increase type safety. + +Using a `Result` type simplifies error handling and reduces `try` `except` blocks. + +## Quick Start +```Python +from option import Result, Option, Ok, Err +from requests import get + + +def call_api(url, params) -> Result[dict, int]: + result = get(url, params) + code = result.status_code + if code == 200: + return Ok(result.json()) + return Err(code) + + +def calculate(url, params) -> Option[int]: + return call_api(url, params).ok().map(len) + + +dict_len = calculate('https://example.com', {}) +``` + +## Install +Option can be installed from PyPi: +```bash +pip install option +``` + +## Documentation +The documentation lives at https://mat1g3r.github.io/option/ + +## License +MIT + + +%package -n python3-option +Summary: Rust like Option and Result types in Python +Provides: python-option +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-option +# Option +[](https://circleci.com/gh/MaT1g3R/option/tree/master) + +Rust-like [Option](https://doc.rust-lang.org/std/option/enum.Option.html) and [Result](https://doc.rust-lang.org/std/result/enum.Result.html) types in Python, slotted and fully typed. + +An `Option` type represents an optional value, every `Option` is either `Some` and contains Some value, or `NONE` + +A `Result` type represents a value that might be an error. Every `Result` is either `Ok` and contains a success value, or `Err` and contains an error value. + +Using an `Option` type forces you to deal with `None` values in your code and increase type safety. + +Using a `Result` type simplifies error handling and reduces `try` `except` blocks. + +## Quick Start +```Python +from option import Result, Option, Ok, Err +from requests import get + + +def call_api(url, params) -> Result[dict, int]: + result = get(url, params) + code = result.status_code + if code == 200: + return Ok(result.json()) + return Err(code) + + +def calculate(url, params) -> Option[int]: + return call_api(url, params).ok().map(len) + + +dict_len = calculate('https://example.com', {}) +``` + +## Install +Option can be installed from PyPi: +```bash +pip install option +``` + +## Documentation +The documentation lives at https://mat1g3r.github.io/option/ + +## License +MIT + + +%package help +Summary: Development documents and examples for option +Provides: python3-option-doc +%description help +# Option +[](https://circleci.com/gh/MaT1g3R/option/tree/master) + +Rust-like [Option](https://doc.rust-lang.org/std/option/enum.Option.html) and [Result](https://doc.rust-lang.org/std/result/enum.Result.html) types in Python, slotted and fully typed. + +An `Option` type represents an optional value, every `Option` is either `Some` and contains Some value, or `NONE` + +A `Result` type represents a value that might be an error. Every `Result` is either `Ok` and contains a success value, or `Err` and contains an error value. + +Using an `Option` type forces you to deal with `None` values in your code and increase type safety. + +Using a `Result` type simplifies error handling and reduces `try` `except` blocks. + +## Quick Start +```Python +from option import Result, Option, Ok, Err +from requests import get + + +def call_api(url, params) -> Result[dict, int]: + result = get(url, params) + code = result.status_code + if code == 200: + return Ok(result.json()) + return Err(code) + + +def calculate(url, params) -> Option[int]: + return call_api(url, params).ok().map(len) + + +dict_len = calculate('https://example.com', {}) +``` + +## Install +Option can be installed from PyPi: +```bash +pip install option +``` + +## Documentation +The documentation lives at https://mat1g3r.github.io/option/ + +## License +MIT + + +%prep +%autosetup -n option-2.1.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-option -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 29 2023 Python_Bot <Python_Bot@openeuler.org> - 2.1.0-1 +- Package Spec generated |
