Skip to main content

A set of tools for simplifying reading and writing of single values to/from Redis.

Project description

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>
'''

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrediseasyio-0.0.20.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

pyrediseasyio-0.0.20-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file pyrediseasyio-0.0.20.tar.gz.

File metadata

  • Download URL: pyrediseasyio-0.0.20.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pyrediseasyio-0.0.20.tar.gz
Algorithm Hash digest
SHA256 d6ebbdc474273a6b39689bef6a740d45172b5b938be54070b2f3efcf4a1379e3
MD5 5e55042428c4b9047d414e2d16256be4
BLAKE2b-256 e062edd8e29499b39831cd9ea4acc773065e17c54570887a179712b1d91c9e31

See more details on using hashes here.

File details

Details for the file pyrediseasyio-0.0.20-py3-none-any.whl.

File metadata

  • Download URL: pyrediseasyio-0.0.20-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for pyrediseasyio-0.0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 636a6cfd9e93e10a948a654fb7d45ff2d4548d87c827aab962d6904c4742f284
MD5 5d80c08a27f2a7ea75cf50b48237d261
BLAKE2b-256 bdd6b0f984c4e0c9002c587b559f1c70af14a060a6866525af7bdb2cac97180c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page