PyRedisEasyIO
A project to simplify reading/writing single objects from/to redis
Description
Redis is a great way to share data between applications - or processes in an application. However, in its raw form, the application has to deal with data type conversion to/from string, check for existence, and other pesky stuff. It would be nice if that were abstracted in such a way to where it didn't appear in code that redis was being used at all.
This project seeks to allow the exchange of single data points in a readable way, eg. my_data.my_value = 30 (automatically writes '30' to redis)
Installation
pip install pyrediseasyio
Usage
The basis of functionality is the IOGroup class. It acts as a container for individual values and performs the behind-the-scenes reads and writes.
from io_group import IOGroup
from single_io import BooleanIO, IntIO, FloatIO
class TestGroup1(IOGroup):
Bool1 = BooleanIO("Boolean 1", "Bool1", False)
Bool2 = BooleanIO("Boolean 2", "Bool2", True)
Int1 = IntIO("Integer 1", "Int1")
Int2 = IntIO("Integer 2", "Int2", default=34)
MyFloat1 = FloatIO("Float 1", "Float1", default=1.2)
class TestGroup2(IOGroup):
Bool1 = BooleanIO("Boolean 1", "Bool1", False)
Bool2 = BooleanIO("Boolean 2", "Bool2", True)
Int1 = IntIO("Integer 1", "Int1")
Int2 = IntIO("Integer 2", "Int2", default=34)
Float1 = FloatIO("Float 1", "Float1", default=1.2)
group1a = TestGroup1()
group1b = TestGroup1()
group2 = TestGroup2()
group1a.MyFloat1 = 1234.5 # Performs redis 'set', sending 1234.5 with key 'Float1'
print(group1b.Float1.value) # Performs redis 'get', calling 'value' converts to primitive type
print(group2.Float1.value)
HTML:
For convenience, methods are provided to automatically generate html. The dominate library is used behind the scenes, giving you first class access to manipulate the html response; Below is an example of usage, consult the test cases for further examples.
class TestGroup(IOGroup):
Bool1 = BooleanIO("Boolean 1", "Bool1", units="On/Off")
Float1 = FloatIO("Float 1", "Float1", default=1.23, units="furlongs")
h = HMTLIOGroup(test_group, "my_id", "my_namespace").html().render()
print(h) #-> Gives;
'''
<div class="my_namespace_io_container" id="my_id_io_container">
<div class="my_namespace_io" id="my_id_Bool1_io">
<div class="my_namespace_io_name">Boolean 1</div>
<div class="my_namespace_io_value" id="my_id_Bool1_io_value" onchange="OnIOValueChange(event)">False</div>
<div class="my_namespace_io_units">On/Off</div>
</div>
<div class="my_namespace_io" id="my_id_Float1_io">
<div class="my_namespace_io_name">Float 1</div>
<div class="my_namespace_io_value" id="my_id_Float1_io_value" onchange="OnIOValueChange(event)">1.23</div>
<div class="my_namespace_io_units">furlongs</div>
</div>
</div>
'''
Release files for pyrediseasyio 0.0.35
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyrediseasyio-0.0.35.tar.gz | 15.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyrediseasyio-0.0.35-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 41.3 kB
Release files / pyrediseasyio-0.0.35.tar.gz
| Download URL | pyrediseasyio-0.0.35.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
847fa65860967f91badc84925f8995f36c5213dc70d7cc9bb03d4913e142839d
|
|
BLAKE2b-256 checksum How to use checksums |
d17c18621f1fb719c0b0300bd4efc7b11488229285e95446c17d13b467a17c99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|
Release files / pyrediseasyio-0.0.35-py3-none-any.whl
| Download URL | pyrediseasyio-0.0.35-py3-none-any.whl |
|---|---|
| Size | 25.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29534e20e705019921fe9237699478425f8e8e6c8ed4735b16dc687a5b2a2ce9
|
|
BLAKE2b-256 checksum How to use checksums |
dc32dd5724b2823f1cc885f44bc1f724f0bee9b458039f6a7ceac545e8b2f361
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|