%global _empty_manifest_terminate_build 0 Name: python-rejson Version: 0.5.6 Release: 1 Summary: RedisJSON Python Client License: BSD-3-Clause URL: https://pypi.org/project/rejson/ Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5f/01/57f0384888d518f04f31582779d8d322e8ec0383d4a90de3b79aff7335d0/rejson-0.5.6.tar.gz BuildArch: noarch Requires: python3-redis Requires: python3-six %description rejson-py is a package that allows storing, updating and querying objects as JSON documents in a [Redis](https://redis.io) database that is extended with the [ReJSON module](https://github.com/redislabsmodules/rejson). The package extends [redis-py](https://github.com/andymccurdy/redis-py)'s interface with ReJSON's API, and performs on-the-fly serialization/deserialization of objects to/from JSON. ## Installation ```bash $ pip install rejson ``` ## Development 1. Create a virtualenv to manage your python dependencies, and ensure it's active. ```virtualenv -v venv``` 2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies. ```pip install --user poetry``` 3. Install dependencies. ```poetry install``` [tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded. ## Usage example ```python from rejson import Client, Path rj = Client(host='localhost', port=6379, decode_responses=True) # Set the key `obj` to some object obj = { 'answer': 42, 'arr': [None, True, 3.14], 'truth': { 'coord': 'out there' } } rj.jsonset('obj', Path.rootPath(), obj) # Get something print 'Is there anybody... {}?'.format( rj.jsonget('obj', Path('.truth.coord')) ) # Delete something (or perhaps nothing), append something and pop it rj.jsondel('obj', Path('.arr[0]')) rj.jsonarrappend('obj', Path('.arr'), 'something') print '{} popped!'.format(rj.jsonarrpop('obj', Path('.arr'))) # Update something else rj.jsonset('obj', Path('.answer'), 2.17) # And use just like the regular redis-py client jp = rj.pipeline() jp.set('foo', 'bar') jp.jsonset('baz', Path.rootPath(), 'qaz') jp.execute() # If you use non-ascii character in your JSON data, you can add the no_escape flag to JSON.GET command obj_non_ascii = { 'non_ascii_string': 'hyvää' } rj.jsonset('non-ascii', Path.rootPath(), obj_non_ascii) print '{} is a non-ascii string'.format(rj.jsonget('non-ascii', Path('.non_ascii_string'), no_escape=True)) ``` ## Encoding/Decoding rejson-py uses Python's [json](https://docs.python.org/2/library/json.html). The client can be set to use custom encoders/decoders at creation, or by calling explicitly the [setEncoder()](./API.md#setencoder) and [setDecoder()](./API.md#setencoder) methods, respectively. The following shows how to use this for a custom class that's stored as a JSON string for example: ```python from json import JSONEncoder, JSONDecoder from rejson import Client class CustomClass(object): "Some non-JSON-serializable" def __init__(self, s=None): if s is not None: # deserialize the instance from the serialization if s.startswith('CustomClass:'): else: raise Exception('unknown format') else: # initialize the instance def __str__(self): _str = 'CustomClass:' # append the instance's state to the serialization return _str class CustomEncoder(JSONEncoder): "A custom encoder for the custom class" def default(self, obj): if isinstance(obj, CustomClass): return str(obj) return json.JSONEncoder.encode(self, obj) class TestDecoder(JSONDecoder): "A custom decoder for the custom class" def decode(self, obj): d = json.JSONDecoder.decode(self, obj) if isinstance(d, basestring) and d.startswith('CustomClass:'): return CustomClass(d) return d # Create a new instance of CustomClass obj = CustomClass() # Create a new client with the custom encoder and decoder rj = Client(encoder=CustomEncoder(), decoder=CustomDecoder()) # Store the object rj.jsonset('custom', Path.rootPath(), obj)) # Retrieve it obj = rj.jsonget('custom', Path.rootPath()) ``` ## API As rejson-py exposes the same methods as redis-py, it can be used as a drop-in replacement. On top of Redis' core commands, the client also adds ReJSON's vocabulary and a couple of helper methods. These are documented in the [API.md](API.md) file, which can be generated by running: ```bash $ python gendoc rejson > API.md ``` For complete documentation about ReJSON's commands, refer to [ReJSON's website](http://rejson.io). ## License [BSD 2-Clause](https://github.com/RedisLabs/rejson-py/blob/master/LICENSE) %package -n python3-rejson Summary: RedisJSON Python Client Provides: python-rejson BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-rejson rejson-py is a package that allows storing, updating and querying objects as JSON documents in a [Redis](https://redis.io) database that is extended with the [ReJSON module](https://github.com/redislabsmodules/rejson). The package extends [redis-py](https://github.com/andymccurdy/redis-py)'s interface with ReJSON's API, and performs on-the-fly serialization/deserialization of objects to/from JSON. ## Installation ```bash $ pip install rejson ``` ## Development 1. Create a virtualenv to manage your python dependencies, and ensure it's active. ```virtualenv -v venv``` 2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies. ```pip install --user poetry``` 3. Install dependencies. ```poetry install``` [tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded. ## Usage example ```python from rejson import Client, Path rj = Client(host='localhost', port=6379, decode_responses=True) # Set the key `obj` to some object obj = { 'answer': 42, 'arr': [None, True, 3.14], 'truth': { 'coord': 'out there' } } rj.jsonset('obj', Path.rootPath(), obj) # Get something print 'Is there anybody... {}?'.format( rj.jsonget('obj', Path('.truth.coord')) ) # Delete something (or perhaps nothing), append something and pop it rj.jsondel('obj', Path('.arr[0]')) rj.jsonarrappend('obj', Path('.arr'), 'something') print '{} popped!'.format(rj.jsonarrpop('obj', Path('.arr'))) # Update something else rj.jsonset('obj', Path('.answer'), 2.17) # And use just like the regular redis-py client jp = rj.pipeline() jp.set('foo', 'bar') jp.jsonset('baz', Path.rootPath(), 'qaz') jp.execute() # If you use non-ascii character in your JSON data, you can add the no_escape flag to JSON.GET command obj_non_ascii = { 'non_ascii_string': 'hyvää' } rj.jsonset('non-ascii', Path.rootPath(), obj_non_ascii) print '{} is a non-ascii string'.format(rj.jsonget('non-ascii', Path('.non_ascii_string'), no_escape=True)) ``` ## Encoding/Decoding rejson-py uses Python's [json](https://docs.python.org/2/library/json.html). The client can be set to use custom encoders/decoders at creation, or by calling explicitly the [setEncoder()](./API.md#setencoder) and [setDecoder()](./API.md#setencoder) methods, respectively. The following shows how to use this for a custom class that's stored as a JSON string for example: ```python from json import JSONEncoder, JSONDecoder from rejson import Client class CustomClass(object): "Some non-JSON-serializable" def __init__(self, s=None): if s is not None: # deserialize the instance from the serialization if s.startswith('CustomClass:'): else: raise Exception('unknown format') else: # initialize the instance def __str__(self): _str = 'CustomClass:' # append the instance's state to the serialization return _str class CustomEncoder(JSONEncoder): "A custom encoder for the custom class" def default(self, obj): if isinstance(obj, CustomClass): return str(obj) return json.JSONEncoder.encode(self, obj) class TestDecoder(JSONDecoder): "A custom decoder for the custom class" def decode(self, obj): d = json.JSONDecoder.decode(self, obj) if isinstance(d, basestring) and d.startswith('CustomClass:'): return CustomClass(d) return d # Create a new instance of CustomClass obj = CustomClass() # Create a new client with the custom encoder and decoder rj = Client(encoder=CustomEncoder(), decoder=CustomDecoder()) # Store the object rj.jsonset('custom', Path.rootPath(), obj)) # Retrieve it obj = rj.jsonget('custom', Path.rootPath()) ``` ## API As rejson-py exposes the same methods as redis-py, it can be used as a drop-in replacement. On top of Redis' core commands, the client also adds ReJSON's vocabulary and a couple of helper methods. These are documented in the [API.md](API.md) file, which can be generated by running: ```bash $ python gendoc rejson > API.md ``` For complete documentation about ReJSON's commands, refer to [ReJSON's website](http://rejson.io). ## License [BSD 2-Clause](https://github.com/RedisLabs/rejson-py/blob/master/LICENSE) %package help Summary: Development documents and examples for rejson Provides: python3-rejson-doc %description help rejson-py is a package that allows storing, updating and querying objects as JSON documents in a [Redis](https://redis.io) database that is extended with the [ReJSON module](https://github.com/redislabsmodules/rejson). The package extends [redis-py](https://github.com/andymccurdy/redis-py)'s interface with ReJSON's API, and performs on-the-fly serialization/deserialization of objects to/from JSON. ## Installation ```bash $ pip install rejson ``` ## Development 1. Create a virtualenv to manage your python dependencies, and ensure it's active. ```virtualenv -v venv``` 2. Install [pypoetry](https://python-poetry.org/) to manage your dependencies. ```pip install --user poetry``` 3. Install dependencies. ```poetry install``` [tox](https://tox.readthedocs.io/en/latest/) runs all tests as its default target. Running *tox* by itself will run unit tests. Ensure you have a running redis, with the module loaded. ## Usage example ```python from rejson import Client, Path rj = Client(host='localhost', port=6379, decode_responses=True) # Set the key `obj` to some object obj = { 'answer': 42, 'arr': [None, True, 3.14], 'truth': { 'coord': 'out there' } } rj.jsonset('obj', Path.rootPath(), obj) # Get something print 'Is there anybody... {}?'.format( rj.jsonget('obj', Path('.truth.coord')) ) # Delete something (or perhaps nothing), append something and pop it rj.jsondel('obj', Path('.arr[0]')) rj.jsonarrappend('obj', Path('.arr'), 'something') print '{} popped!'.format(rj.jsonarrpop('obj', Path('.arr'))) # Update something else rj.jsonset('obj', Path('.answer'), 2.17) # And use just like the regular redis-py client jp = rj.pipeline() jp.set('foo', 'bar') jp.jsonset('baz', Path.rootPath(), 'qaz') jp.execute() # If you use non-ascii character in your JSON data, you can add the no_escape flag to JSON.GET command obj_non_ascii = { 'non_ascii_string': 'hyvää' } rj.jsonset('non-ascii', Path.rootPath(), obj_non_ascii) print '{} is a non-ascii string'.format(rj.jsonget('non-ascii', Path('.non_ascii_string'), no_escape=True)) ``` ## Encoding/Decoding rejson-py uses Python's [json](https://docs.python.org/2/library/json.html). The client can be set to use custom encoders/decoders at creation, or by calling explicitly the [setEncoder()](./API.md#setencoder) and [setDecoder()](./API.md#setencoder) methods, respectively. The following shows how to use this for a custom class that's stored as a JSON string for example: ```python from json import JSONEncoder, JSONDecoder from rejson import Client class CustomClass(object): "Some non-JSON-serializable" def __init__(self, s=None): if s is not None: # deserialize the instance from the serialization if s.startswith('CustomClass:'): else: raise Exception('unknown format') else: # initialize the instance def __str__(self): _str = 'CustomClass:' # append the instance's state to the serialization return _str class CustomEncoder(JSONEncoder): "A custom encoder for the custom class" def default(self, obj): if isinstance(obj, CustomClass): return str(obj) return json.JSONEncoder.encode(self, obj) class TestDecoder(JSONDecoder): "A custom decoder for the custom class" def decode(self, obj): d = json.JSONDecoder.decode(self, obj) if isinstance(d, basestring) and d.startswith('CustomClass:'): return CustomClass(d) return d # Create a new instance of CustomClass obj = CustomClass() # Create a new client with the custom encoder and decoder rj = Client(encoder=CustomEncoder(), decoder=CustomDecoder()) # Store the object rj.jsonset('custom', Path.rootPath(), obj)) # Retrieve it obj = rj.jsonget('custom', Path.rootPath()) ``` ## API As rejson-py exposes the same methods as redis-py, it can be used as a drop-in replacement. On top of Redis' core commands, the client also adds ReJSON's vocabulary and a couple of helper methods. These are documented in the [API.md](API.md) file, which can be generated by running: ```bash $ python gendoc rejson > API.md ``` For complete documentation about ReJSON's commands, refer to [ReJSON's website](http://rejson.io). ## License [BSD 2-Clause](https://github.com/RedisLabs/rejson-py/blob/master/LICENSE) %prep %autosetup -n rejson-0.5.6 %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-rejson -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue Apr 25 2023 Python_Bot - 0.5.6-1 - Package Spec generated