!1 python-warlock:Add source packages and spec file
From: @zhangy1317 Reviewed-by: @shinwell_hu Signed-off-by: @shinwell_hu
This commit is contained in:
commit
566b53ab04
224
python-warlock.spec
Normal file
224
python-warlock.spec
Normal file
@ -0,0 +1,224 @@
|
||||
%global _empty_manifest_terminate_build 0
|
||||
Name: python-warlock
|
||||
Version: 1.3.3
|
||||
Release: 1
|
||||
Summary: Python object model built on JSON schema and JSON patch.
|
||||
License: Apache-2.0
|
||||
URL: http://github.com/bcwaldon/warlock
|
||||
Source0: https://files.pythonhosted.org/packages/c2/36/178b26a338cd6d30523246da4721b1114306f588deb813f3f503052825ee/warlock-1.3.3.tar.gz
|
||||
BuildArch: noarch
|
||||
|
||||
|
||||
%description
|
||||
Warlock — self-validating Python objects using JSON schema
|
||||
|
||||
|
||||
%package -n python3-warlock
|
||||
Summary: Python object model built on JSON schema and JSON patch.
|
||||
Provides: python-warlock
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
%description -n python3-warlock
|
||||
# Warlock — self-validating Python objects using JSON schema
|
||||
|
||||
[][warlock]
|
||||
[][warlock]
|
||||
[][pypistats]
|
||||
|
||||
[][ci-builds]
|
||||
[][coveralls]
|
||||
|
||||
## Installation
|
||||
|
||||
Warlock is [available on PyPI][warlock]:
|
||||
|
||||
```shell
|
||||
pip install warlock
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1) Create your schema
|
||||
|
||||
```python
|
||||
>>> schema = {
|
||||
'name': 'Country',
|
||||
'properties': {
|
||||
'name': {'type': 'string'},
|
||||
'abbreviation': {'type': 'string'},
|
||||
'population': {'type': 'integer'},
|
||||
},
|
||||
'additionalProperties': False,
|
||||
}
|
||||
```
|
||||
|
||||
2) Create a model
|
||||
|
||||
```python
|
||||
>>> import warlock
|
||||
>>> Country = warlock.model_factory(schema)
|
||||
```
|
||||
|
||||
3) Create an object using your model
|
||||
|
||||
```python
|
||||
>>> sweden = Country(name='Sweden', abbreviation='SE')
|
||||
```
|
||||
|
||||
4) Let the object validate itself
|
||||
|
||||
```python
|
||||
>>> sweden.name = 5
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in <module>
|
||||
File "warlock/core.py", line 53, in __setattr__
|
||||
raise InvalidOperation(msg)
|
||||
warlock.core.InvalidOperation: Unable to set 'name' to '5'
|
||||
|
||||
>>> sweden.overlord = 'Bears'
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in <module>
|
||||
File "warlock/core.py", line 53, in __setattr__
|
||||
raise InvalidOperation(msg)
|
||||
warlock.core.InvalidOperation: Unable to set 'overlord' to 'Bears'
|
||||
```
|
||||
|
||||
5) Generate a [JSON Patch document](http://tools.ietf.org/html/draft-ietf-appsawg-json-patch) to track changes
|
||||
|
||||
```python
|
||||
>>> sweden.population=9453000
|
||||
>>> sweden.patch
|
||||
'[{"path": "/population", "value": 9453000, "op": "add"}]'
|
||||
```
|
||||
|
||||
[warlock]: https://pypi.org/project/warlock/
|
||||
[pip]: https://pip.pypa.io/en/stable/
|
||||
[ci-builds]: https://travis-ci.org/bcwaldon/warlock
|
||||
[coveralls]: https://coveralls.io/github/bcwaldon/warlock?branch=master
|
||||
[pypistats]: https://pypistats.org/packages/warlock
|
||||
|
||||
%package help
|
||||
Summary: Development documents and examples for warlock
|
||||
Provides: python3-warlock-doc
|
||||
%description help
|
||||
# Warlock — self-validating Python objects using JSON schema
|
||||
|
||||
[][warlock]
|
||||
[][warlock]
|
||||
[][pypistats]
|
||||
|
||||
[][ci-builds]
|
||||
[][coveralls]
|
||||
|
||||
## Installation
|
||||
|
||||
Warlock is [available on PyPI][warlock]:
|
||||
|
||||
```shell
|
||||
pip install warlock
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
1) Create your schema
|
||||
|
||||
```python
|
||||
>>> schema = {
|
||||
'name': 'Country',
|
||||
'properties': {
|
||||
'name': {'type': 'string'},
|
||||
'abbreviation': {'type': 'string'},
|
||||
'population': {'type': 'integer'},
|
||||
},
|
||||
'additionalProperties': False,
|
||||
}
|
||||
```
|
||||
|
||||
2) Create a model
|
||||
|
||||
```python
|
||||
>>> import warlock
|
||||
>>> Country = warlock.model_factory(schema)
|
||||
```
|
||||
|
||||
3) Create an object using your model
|
||||
|
||||
```python
|
||||
>>> sweden = Country(name='Sweden', abbreviation='SE')
|
||||
```
|
||||
|
||||
4) Let the object validate itself
|
||||
|
||||
```python
|
||||
>>> sweden.name = 5
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in <module>
|
||||
File "warlock/core.py", line 53, in __setattr__
|
||||
raise InvalidOperation(msg)
|
||||
warlock.core.InvalidOperation: Unable to set 'name' to '5'
|
||||
|
||||
>>> sweden.overlord = 'Bears'
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 1, in <module>
|
||||
File "warlock/core.py", line 53, in __setattr__
|
||||
raise InvalidOperation(msg)
|
||||
warlock.core.InvalidOperation: Unable to set 'overlord' to 'Bears'
|
||||
```
|
||||
|
||||
5) Generate a [JSON Patch document](http://tools.ietf.org/html/draft-ietf-appsawg-json-patch) to track changes
|
||||
|
||||
```python
|
||||
>>> sweden.population=9453000
|
||||
>>> sweden.patch
|
||||
'[{"path": "/population", "value": 9453000, "op": "add"}]'
|
||||
```
|
||||
|
||||
[warlock]: https://pypi.org/project/warlock/
|
||||
[pip]: https://pip.pypa.io/en/stable/
|
||||
[ci-builds]: https://travis-ci.org/bcwaldon/warlock
|
||||
[coveralls]: https://coveralls.io/github/bcwaldon/warlock?branch=master
|
||||
[pypistats]: https://pypistats.org/packages/warlock
|
||||
|
||||
%prep
|
||||
%autosetup -n warlock-1.3.3
|
||||
|
||||
%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-warlock -f filelist.lst
|
||||
%dir %{python3_sitelib}/*
|
||||
|
||||
%files help -f doclist.lst
|
||||
%{_docdir}/*
|
||||
|
||||
%changelog
|
||||
* Mon Nov 23 2020 Python_Bot <Python_Bot@openeuler.org>
|
||||
- Package Spec generated
|
||||
BIN
warlock-1.3.3.tar.gz
Normal file
BIN
warlock-1.3.3.tar.gz
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user