diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-18 05:45:13 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-18 05:45:13 +0000 |
commit | 09d65f1b60da295be95f81f708e9b975336ea7a3 (patch) | |
tree | 078c278c94d17bbd60313150ac4929b8c53b5538 | |
parent | b028eda3acfa3d2a0e1d1c0df2f2d13c53e39445 (diff) |
automatic import of python-district42
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-district42.spec | 1063 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 1065 insertions, 0 deletions
@@ -0,0 +1 @@ +/district42-1.5.1.tar.gz diff --git a/python-district42.spec b/python-district42.spec new file mode 100644 index 0000000..f8a7c58 --- /dev/null +++ b/python-district42.spec @@ -0,0 +1,1063 @@ +%global _empty_manifest_terminate_build 0 +Name: python-district42 +Version: 1.5.1 +Release: 1 +Summary: Data description language for defining data models +License: Apache-2.0 +URL: https://github.com/nikitanovosibirsk/district42 +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/69/26/657c3cc5f5b3e2e52af058297980d6a4c5d20c6fd224a08bdaa03133b58c/district42-1.5.1.tar.gz +BuildArch: noarch + +Requires: python3-niltype + +%description +# district42 + +[](https://codecov.io/gh/nikitanovosibirsk/district42) +[](https://pypi.python.org/pypi/district42/) +[](https://pypi.python.org/pypi/district42/) +[](https://pypi.python.org/pypi/district42/) + +Data description language for defining data models + +## Installation + +```sh +pip3 install district42 +``` + +## Usage + +```python +from district42 import schema + +UserSchema = schema.dict({ + "id": schema.int.min(1), + "name": schema.str | schema.none, + "is_deleted": schema.bool, +}) + +print(UserSchema) +``` + +More powerful with: +- [blahblah](https://github.com/nikitanovosibirsk/blahblah) — Fake data generator +- [valera](https://github.com/nikitanovosibirsk/valera) — Validator +- [revolt](https://github.com/nikitanovosibirsk/revolt) — Value substitutor + +And [more](https://github.com/topics/district42) + + +## Documentation + +* [Documentation](#documentation) + * [None](#none) + * [schema.none](#schemanone) + * [Bool](#bool) + * [schema.bool](#schemabool) + * [schema.bool(`value`)](#schemaboolvalue) + * [Int](#int) + * [schema.int](#schemaint) + * [schema.int(`value`)](#schemaintvalue) + * [schema.int.min(`value`)](#schemaintminvalue) + * [schema.int.max(`value`)](#schemaintmaxvalue) + * [Float](#float) + * [schema.float](#schemafloat) + * [schema.float(`value`)](#schemafloatvalue) + * [schema.float.min(`value`)](#schemafloatminvalue) + * [schema.float.max(`value`)](#schemafloatmaxvalue) + * [Str](#str) + * [schema.str](#schemastr) + * [schema.str.len(`length`)](#schemastrlenlength) + * [schema.str.len(`min_length`, `max_length`)](#schemastrlenmin_length-max_length) + * [schema.str.alphabet(`letters`)](#schemastralphabetletters) + * [schema.str.contains(`substr`)](#schemastrcontainssubstr) + * [schema.str.regex(`pattern`)](#schemastrregexpattern) + * [List](#list) + * [schema.list](#schemalist) + * [schema.list(`elements`)](#schemalistelements) + * [schema.list(`type`)](#schemalisttype) + * [schema.list(`type`).len(`length`)](#schemalisttypelenlength) + * [schema.list(`type`).len(`min_length`, `max_length`)](#schemalisttypelenmin_length-max_length) + * [Dict](#dict) + * [schema.dict](#schemadict) + * [schema.dict(`keys`)](#schemadictkeys) + * [Any](#any) + * [schema.any](#schemaany) + * [schema.any(`*types`)](#schemaanytypes) + * [Custom Types](#custom-types) + * [1. Declare Schema](#1-declare-schema) + * [2. Register Representor](#2-register-representor) + * [3. Use](#3-use) + +### None + +#### schema.none + +```python +sch = schema.none +``` + +### Bool + +#### schema.bool + +```python +sch = schema.bool +``` + +#### schema.bool(`value`) + +```python +sch = schema.bool(True) +``` + +### Int + +#### schema.int + +```python +sch = schema.int +``` + +#### schema.int(`value`) + +```python +sch = schema.int(42) +``` + +#### schema.int.min(`value`) + +```python +sch = schema.int.min(0) +``` + +#### schema.int.max(`value`) + +```python +sch = schema.int.max(0) +``` + +### Float + +#### schema.float + +```python +sch = schema.float +``` + +#### schema.float(`value`) + +```python +sch = schema.float(3.14) +``` + +#### schema.float.min(`value`) + +```python +sch = schema.float.min(0.0) +``` + +#### schema.float.max(`value`) + +```python +sch = schema.float.max(0.0) +``` + +### Str + +#### schema.str + +```python +sch = schema.str +``` + +#### schema.str.len(`length`) + +```python +sch = schema.str.len(10) +``` + +#### schema.str.len(`min_length`, `max_length`) + +```python +sch = schema.str.len(1, ...) +``` + +```python +sch = schema.str.len(..., 32) +``` + +```python +sch = schema.str.len(1, 32) +``` + +#### schema.str.alphabet(`letters`) + +```python +digits = "01234567890" +sch = schema.str.alphabet(digits) +``` + +#### schema.str.contains(`substr`) + +```python +sch = schema.str.contains("@") +``` + +#### schema.str.regex(`pattern`) + +```python +import re +sch = schema.str.regex(r"[a-z]+") +``` + +### List + +#### schema.list + +```python +sch = schema.list +``` + +#### schema.list(`elements`) + +```python +sch = schema.list([schema.int(1), schema.int(2)]) +``` + +#### schema.list(`type`) + +```python +sch = schema.list(schema.int) +``` + +#### schema.list(`type`).len(`length`) + +```python +sch = schema.list(schema.int).len(3) +``` + +#### schema.list(`type`).len(`min_length`, `max_length`) + +```python +sch = schema.list(schema.int).len(1, ...) +``` + +```python +sch = schema.list(schema.int).len(..., 10) +``` + +```python +sch = schema.list(schema.int).len(1, 10) +``` + +### Dict + +#### schema.dict + +```python +sch = schema.dict +``` + +#### schema.dict(`keys`) + +```python +sch = schema.dict({ + "id": schema.int, + "name": schema.str | schema.none, + optional("platform"): schema.str, +}) +``` + +### Any + +#### schema.any + +```python +sch = schema.any +``` + +#### schema.any(`*types`) + +```python +sch = schema.any(schema.str, schema.int) +``` + +### Custom Types + +#### 1. Declare Schema + +```python +from typing import Any +from uuid import UUID +from district42 import Props, SchemaVisitor, SchemaVisitorReturnType as ReturnType +from district42.types import Schema +from niltype import Nilable + + +class UUIDProps(Props): + @property + def value(self) -> Nilable[UUID]: + return self.get("value") + + +class UUIDSchema(Schema[UUIDProps]): + def __accept__(self, visitor: SchemaVisitor[ReturnType], **kwargs: Any) -> ReturnType: + return visitor.visit_uuid(self, **kwargs) + + def __call__(self, /, value: UUID) -> "UUIDSchema": + return self.__class__(self.props.update(value=value)) +``` + +#### 2. Register Representor + +```python +from typing import Any +from district42.representor import Representor +from niltype import Nil + + +class UUIDRepresentor(Representor, extend=True): + def visit_uuid(self, schema: UUIDSchema, *, indent: int = 0, **kwargs: Any) -> str: + r = f"{self._name}.uuid" + + if schema.props.value is not Nil: + r += f"({schema.props.value!r})" + + return r +``` + +#### 3. Use + +```python +from uuid import uuid4 +from district42 import register_type, schema + +register_type("uuid", UUIDSchema) + +print(schema.uuid(uuid4())) +# schema.uuid(UUID('ce80d2b7-cdce-4e24-ab26-00c75471ce78')) +``` + +Full code available here: [district42_exp_types/uuid](https://github.com/nikitanovosibirsk/district42-exp-types/tree/master/district42_exp_types/uuid) + + +%package -n python3-district42 +Summary: Data description language for defining data models +Provides: python-district42 +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-district42 +# district42 + +[](https://codecov.io/gh/nikitanovosibirsk/district42) +[](https://pypi.python.org/pypi/district42/) +[](https://pypi.python.org/pypi/district42/) +[](https://pypi.python.org/pypi/district42/) + +Data description language for defining data models + +## Installation + +```sh +pip3 install district42 +``` + +## Usage + +```python +from district42 import schema + +UserSchema = schema.dict({ + "id": schema.int.min(1), + "name": schema.str | schema.none, + "is_deleted": schema.bool, +}) + +print(UserSchema) +``` + +More powerful with: +- [blahblah](https://github.com/nikitanovosibirsk/blahblah) — Fake data generator +- [valera](https://github.com/nikitanovosibirsk/valera) — Validator +- [revolt](https://github.com/nikitanovosibirsk/revolt) — Value substitutor + +And [more](https://github.com/topics/district42) + + +## Documentation + +* [Documentation](#documentation) + * [None](#none) + * [schema.none](#schemanone) + * [Bool](#bool) + * [schema.bool](#schemabool) + * [schema.bool(`value`)](#schemaboolvalue) + * [Int](#int) + * [schema.int](#schemaint) + * [schema.int(`value`)](#schemaintvalue) + * [schema.int.min(`value`)](#schemaintminvalue) + * [schema.int.max(`value`)](#schemaintmaxvalue) + * [Float](#float) + * [schema.float](#schemafloat) + * [schema.float(`value`)](#schemafloatvalue) + * [schema.float.min(`value`)](#schemafloatminvalue) + * [schema.float.max(`value`)](#schemafloatmaxvalue) + * [Str](#str) + * [schema.str](#schemastr) + * [schema.str.len(`length`)](#schemastrlenlength) + * [schema.str.len(`min_length`, `max_length`)](#schemastrlenmin_length-max_length) + * [schema.str.alphabet(`letters`)](#schemastralphabetletters) + * [schema.str.contains(`substr`)](#schemastrcontainssubstr) + * [schema.str.regex(`pattern`)](#schemastrregexpattern) + * [List](#list) + * [schema.list](#schemalist) + * [schema.list(`elements`)](#schemalistelements) + * [schema.list(`type`)](#schemalisttype) + * [schema.list(`type`).len(`length`)](#schemalisttypelenlength) + * [schema.list(`type`).len(`min_length`, `max_length`)](#schemalisttypelenmin_length-max_length) + * [Dict](#dict) + * [schema.dict](#schemadict) + * [schema.dict(`keys`)](#schemadictkeys) + * [Any](#any) + * [schema.any](#schemaany) + * [schema.any(`*types`)](#schemaanytypes) + * [Custom Types](#custom-types) + * [1. Declare Schema](#1-declare-schema) + * [2. Register Representor](#2-register-representor) + * [3. Use](#3-use) + +### None + +#### schema.none + +```python +sch = schema.none +``` + +### Bool + +#### schema.bool + +```python +sch = schema.bool +``` + +#### schema.bool(`value`) + +```python +sch = schema.bool(True) +``` + +### Int + +#### schema.int + +```python +sch = schema.int +``` + +#### schema.int(`value`) + +```python +sch = schema.int(42) +``` + +#### schema.int.min(`value`) + +```python +sch = schema.int.min(0) +``` + +#### schema.int.max(`value`) + +```python +sch = schema.int.max(0) +``` + +### Float + +#### schema.float + +```python +sch = schema.float +``` + +#### schema.float(`value`) + +```python +sch = schema.float(3.14) +``` + +#### schema.float.min(`value`) + +```python +sch = schema.float.min(0.0) +``` + +#### schema.float.max(`value`) + +```python +sch = schema.float.max(0.0) +``` + +### Str + +#### schema.str + +```python +sch = schema.str +``` + +#### schema.str.len(`length`) + +```python +sch = schema.str.len(10) +``` + +#### schema.str.len(`min_length`, `max_length`) + +```python +sch = schema.str.len(1, ...) +``` + +```python +sch = schema.str.len(..., 32) +``` + +```python +sch = schema.str.len(1, 32) +``` + +#### schema.str.alphabet(`letters`) + +```python +digits = "01234567890" +sch = schema.str.alphabet(digits) +``` + +#### schema.str.contains(`substr`) + +```python +sch = schema.str.contains("@") +``` + +#### schema.str.regex(`pattern`) + +```python +import re +sch = schema.str.regex(r"[a-z]+") +``` + +### List + +#### schema.list + +```python +sch = schema.list +``` + +#### schema.list(`elements`) + +```python +sch = schema.list([schema.int(1), schema.int(2)]) +``` + +#### schema.list(`type`) + +```python +sch = schema.list(schema.int) +``` + +#### schema.list(`type`).len(`length`) + +```python +sch = schema.list(schema.int).len(3) +``` + +#### schema.list(`type`).len(`min_length`, `max_length`) + +```python +sch = schema.list(schema.int).len(1, ...) +``` + +```python +sch = schema.list(schema.int).len(..., 10) +``` + +```python +sch = schema.list(schema.int).len(1, 10) +``` + +### Dict + +#### schema.dict + +```python +sch = schema.dict +``` + +#### schema.dict(`keys`) + +```python +sch = schema.dict({ + "id": schema.int, + "name": schema.str | schema.none, + optional("platform"): schema.str, +}) +``` + +### Any + +#### schema.any + +```python +sch = schema.any +``` + +#### schema.any(`*types`) + +```python +sch = schema.any(schema.str, schema.int) +``` + +### Custom Types + +#### 1. Declare Schema + +```python +from typing import Any +from uuid import UUID +from district42 import Props, SchemaVisitor, SchemaVisitorReturnType as ReturnType +from district42.types import Schema +from niltype import Nilable + + +class UUIDProps(Props): + @property + def value(self) -> Nilable[UUID]: + return self.get("value") + + +class UUIDSchema(Schema[UUIDProps]): + def __accept__(self, visitor: SchemaVisitor[ReturnType], **kwargs: Any) -> ReturnType: + return visitor.visit_uuid(self, **kwargs) + + def __call__(self, /, value: UUID) -> "UUIDSchema": + return self.__class__(self.props.update(value=value)) +``` + +#### 2. Register Representor + +```python +from typing import Any +from district42.representor import Representor +from niltype import Nil + + +class UUIDRepresentor(Representor, extend=True): + def visit_uuid(self, schema: UUIDSchema, *, indent: int = 0, **kwargs: Any) -> str: + r = f"{self._name}.uuid" + + if schema.props.value is not Nil: + r += f"({schema.props.value!r})" + + return r +``` + +#### 3. Use + +```python +from uuid import uuid4 +from district42 import register_type, schema + +register_type("uuid", UUIDSchema) + +print(schema.uuid(uuid4())) +# schema.uuid(UUID('ce80d2b7-cdce-4e24-ab26-00c75471ce78')) +``` + +Full code available here: [district42_exp_types/uuid](https://github.com/nikitanovosibirsk/district42-exp-types/tree/master/district42_exp_types/uuid) + + +%package help +Summary: Development documents and examples for district42 +Provides: python3-district42-doc +%description help +# district42 + +[](https://codecov.io/gh/nikitanovosibirsk/district42) +[](https://pypi.python.org/pypi/district42/) +[](https://pypi.python.org/pypi/district42/) +[](https://pypi.python.org/pypi/district42/) + +Data description language for defining data models + +## Installation + +```sh +pip3 install district42 +``` + +## Usage + +```python +from district42 import schema + +UserSchema = schema.dict({ + "id": schema.int.min(1), + "name": schema.str | schema.none, + "is_deleted": schema.bool, +}) + +print(UserSchema) +``` + +More powerful with: +- [blahblah](https://github.com/nikitanovosibirsk/blahblah) — Fake data generator +- [valera](https://github.com/nikitanovosibirsk/valera) — Validator +- [revolt](https://github.com/nikitanovosibirsk/revolt) — Value substitutor + +And [more](https://github.com/topics/district42) + + +## Documentation + +* [Documentation](#documentation) + * [None](#none) + * [schema.none](#schemanone) + * [Bool](#bool) + * [schema.bool](#schemabool) + * [schema.bool(`value`)](#schemaboolvalue) + * [Int](#int) + * [schema.int](#schemaint) + * [schema.int(`value`)](#schemaintvalue) + * [schema.int.min(`value`)](#schemaintminvalue) + * [schema.int.max(`value`)](#schemaintmaxvalue) + * [Float](#float) + * [schema.float](#schemafloat) + * [schema.float(`value`)](#schemafloatvalue) + * [schema.float.min(`value`)](#schemafloatminvalue) + * [schema.float.max(`value`)](#schemafloatmaxvalue) + * [Str](#str) + * [schema.str](#schemastr) + * [schema.str.len(`length`)](#schemastrlenlength) + * [schema.str.len(`min_length`, `max_length`)](#schemastrlenmin_length-max_length) + * [schema.str.alphabet(`letters`)](#schemastralphabetletters) + * [schema.str.contains(`substr`)](#schemastrcontainssubstr) + * [schema.str.regex(`pattern`)](#schemastrregexpattern) + * [List](#list) + * [schema.list](#schemalist) + * [schema.list(`elements`)](#schemalistelements) + * [schema.list(`type`)](#schemalisttype) + * [schema.list(`type`).len(`length`)](#schemalisttypelenlength) + * [schema.list(`type`).len(`min_length`, `max_length`)](#schemalisttypelenmin_length-max_length) + * [Dict](#dict) + * [schema.dict](#schemadict) + * [schema.dict(`keys`)](#schemadictkeys) + * [Any](#any) + * [schema.any](#schemaany) + * [schema.any(`*types`)](#schemaanytypes) + * [Custom Types](#custom-types) + * [1. Declare Schema](#1-declare-schema) + * [2. Register Representor](#2-register-representor) + * [3. Use](#3-use) + +### None + +#### schema.none + +```python +sch = schema.none +``` + +### Bool + +#### schema.bool + +```python +sch = schema.bool +``` + +#### schema.bool(`value`) + +```python +sch = schema.bool(True) +``` + +### Int + +#### schema.int + +```python +sch = schema.int +``` + +#### schema.int(`value`) + +```python +sch = schema.int(42) +``` + +#### schema.int.min(`value`) + +```python +sch = schema.int.min(0) +``` + +#### schema.int.max(`value`) + +```python +sch = schema.int.max(0) +``` + +### Float + +#### schema.float + +```python +sch = schema.float +``` + +#### schema.float(`value`) + +```python +sch = schema.float(3.14) +``` + +#### schema.float.min(`value`) + +```python +sch = schema.float.min(0.0) +``` + +#### schema.float.max(`value`) + +```python +sch = schema.float.max(0.0) +``` + +### Str + +#### schema.str + +```python +sch = schema.str +``` + +#### schema.str.len(`length`) + +```python +sch = schema.str.len(10) +``` + +#### schema.str.len(`min_length`, `max_length`) + +```python +sch = schema.str.len(1, ...) +``` + +```python +sch = schema.str.len(..., 32) +``` + +```python +sch = schema.str.len(1, 32) +``` + +#### schema.str.alphabet(`letters`) + +```python +digits = "01234567890" +sch = schema.str.alphabet(digits) +``` + +#### schema.str.contains(`substr`) + +```python +sch = schema.str.contains("@") +``` + +#### schema.str.regex(`pattern`) + +```python +import re +sch = schema.str.regex(r"[a-z]+") +``` + +### List + +#### schema.list + +```python +sch = schema.list +``` + +#### schema.list(`elements`) + +```python +sch = schema.list([schema.int(1), schema.int(2)]) +``` + +#### schema.list(`type`) + +```python +sch = schema.list(schema.int) +``` + +#### schema.list(`type`).len(`length`) + +```python +sch = schema.list(schema.int).len(3) +``` + +#### schema.list(`type`).len(`min_length`, `max_length`) + +```python +sch = schema.list(schema.int).len(1, ...) +``` + +```python +sch = schema.list(schema.int).len(..., 10) +``` + +```python +sch = schema.list(schema.int).len(1, 10) +``` + +### Dict + +#### schema.dict + +```python +sch = schema.dict +``` + +#### schema.dict(`keys`) + +```python +sch = schema.dict({ + "id": schema.int, + "name": schema.str | schema.none, + optional("platform"): schema.str, +}) +``` + +### Any + +#### schema.any + +```python +sch = schema.any +``` + +#### schema.any(`*types`) + +```python +sch = schema.any(schema.str, schema.int) +``` + +### Custom Types + +#### 1. Declare Schema + +```python +from typing import Any +from uuid import UUID +from district42 import Props, SchemaVisitor, SchemaVisitorReturnType as ReturnType +from district42.types import Schema +from niltype import Nilable + + +class UUIDProps(Props): + @property + def value(self) -> Nilable[UUID]: + return self.get("value") + + +class UUIDSchema(Schema[UUIDProps]): + def __accept__(self, visitor: SchemaVisitor[ReturnType], **kwargs: Any) -> ReturnType: + return visitor.visit_uuid(self, **kwargs) + + def __call__(self, /, value: UUID) -> "UUIDSchema": + return self.__class__(self.props.update(value=value)) +``` + +#### 2. Register Representor + +```python +from typing import Any +from district42.representor import Representor +from niltype import Nil + + +class UUIDRepresentor(Representor, extend=True): + def visit_uuid(self, schema: UUIDSchema, *, indent: int = 0, **kwargs: Any) -> str: + r = f"{self._name}.uuid" + + if schema.props.value is not Nil: + r += f"({schema.props.value!r})" + + return r +``` + +#### 3. Use + +```python +from uuid import uuid4 +from district42 import register_type, schema + +register_type("uuid", UUIDSchema) + +print(schema.uuid(uuid4())) +# schema.uuid(UUID('ce80d2b7-cdce-4e24-ab26-00c75471ce78')) +``` + +Full code available here: [district42_exp_types/uuid](https://github.com/nikitanovosibirsk/district42-exp-types/tree/master/district42_exp_types/uuid) + + +%prep +%autosetup -n district42-1.5.1 + +%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-district42 -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Thu May 18 2023 Python_Bot <Python_Bot@openeuler.org> - 1.5.1-1 +- Package Spec generated @@ -0,0 +1 @@ +89c9355558baad48dfaff57491740dcf district42-1.5.1.tar.gz |