Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/washad/PyRedisEasyIO
Browse files Browse the repository at this point in the history
Forgot to pull first, what a dummy
  • Loading branch information
washad committed Jun 22, 2019
2 parents 075a7c3 + f7183f8 commit 1e7622d
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build/lib/pyrediseasyio/io_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, host='localhost', port=6379, db=0,
delete_keys_on_startup: bool = False, **kwargs):

super().__init__(host=host, port=port, db=db, **kwargs)
member_names = [d for d in dir(self) if not d.startswith('__')]
member_names = [d for d in dir(self) if not d.startswith('_')]
self.members = []
for name in member_names:
try:
Expand Down
75 changes: 67 additions & 8 deletions build/lib/pyrediseasyio/single_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,93 @@ def __mul__(self, other):
other = other.value
return self.value * other

def __truediv__(self, other):
def __eq__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value / other
return self.value == other

def __floordiv__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value // other

def __eq__(self, other):
def __iadd__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value == other
val = self.value
val += other
self.write(val)

def __idiv__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val /= other
self.write(val)

def __ifloordiv__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val //= other
self.write(val)

def __imul__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val *= other
self.write(val)

def __invert__(self):
return ~self.value

def __ipow__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val **= other
self.write(val)

def __isub__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val -= other
self.write(val)

def __ne__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value != other

def __get__(self, instance, owner):
self.read()
return self
def __or__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value or other

def __pos__(self):
return self.value

def __pow__(self, power, modulo=None):
if hasattr(power, 'value'):
power = power.value
return self.value ** power

def __neg__(self):
return -self.value

def __set__(self, obj, value):
self.write(value)

def __str__(self):
return f'[{type(self).__name__}] {self.name} = {self.value} {self.units}'

def __truediv__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value / other

@property
def value(self):
return self.read()
Expand All @@ -72,10 +129,12 @@ def value(self):
def _convert_type(value):
return value

def publish(self, value, channel: str = None):
def publish(self, value, channel: str = None, and_write: bool = False):
value = self._convert_type(value)
data = json.dumps({self.addr: value})
self._reader_writer.publish(data, channel)
if and_write:
self.write(value)

def read(self):
if self._reader_writer is None:
Expand Down
Binary file added dist/pyrediseasyio-0.0.14-py3-none-any.whl
Binary file not shown.
Binary file added dist/pyrediseasyio-0.0.14.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion pyrediseasyio.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: pyrediseasyio
Version: 0.0.11
Version: 0.0.14
Summary: A set of tools for simplifying reading and writing of single values to/from Redis.
Home-page: https://github.com/washad/PyRedisEasyIO
Author: Steve Jackson
Expand Down
75 changes: 67 additions & 8 deletions pyrediseasyio/io/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,93 @@ def __mul__(self, other):
other = other.value
return self.value * other

def __truediv__(self, other):
def __eq__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value / other
return self.value == other

def __floordiv__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value // other

def __eq__(self, other):
def __iadd__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value == other
val = self.value
val += other
self.write(val)

def __idiv__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val /= other
self.write(val)

def __ifloordiv__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val //= other
self.write(val)

def __imul__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val *= other
self.write(val)

def __invert__(self):
return ~self.value

def __ipow__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val **= other
self.write(val)

def __isub__(self, other):
if hasattr(other, 'value'):
other = other.value
val = self.value
val -= other
self.write(val)

def __ne__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value != other

def __get__(self, instance, owner):
self.read()
return self
def __or__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value or other

def __pos__(self):
return self.value

def __pow__(self, power, modulo=None):
if hasattr(power, 'value'):
power = power.value
return self.value ** power

def __neg__(self):
return -self.value

def __set__(self, obj, value):
self.write(value)

def __str__(self):
return f'[{type(self).__name__}] {self.name} = {self.value} {self.units}'

def __truediv__(self, other):
if hasattr(other, 'value'):
other = other.value
return self.value / other

@property
def value(self):
return self.read()
Expand All @@ -72,10 +129,12 @@ def value(self):
def _convert_type(value):
return value

def publish(self, value, channel: str = None):
def publish(self, value, channel: str = None, and_write: bool = False):
value = self._convert_type(value)
data = json.dumps({self.addr: value})
self._reader_writer.publish(data, channel)
if and_write:
self.write(value)

def read(self):
if self._reader_writer is None:
Expand Down
2 changes: 1 addition & 1 deletion pyrediseasyio/io/io_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self, host='localhost', port=6379, db=0,
delete_keys_on_startup: bool = False, **kwargs):

super().__init__(host=host, port=port, db=db, **kwargs)
member_names = [d for d in dir(self) if not d.startswith('__')]
member_names = [d for d in dir(self) if not d.startswith('_')]
self.members = []
for name in member_names:
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="pyrediseasyio",
version="0.0.11",
version="0.0.14",
author="Steve Jackson",
author_email="washad@gmail.com",
description="A set of tools for simplifying reading and writing of single values to/from Redis.",
Expand Down

0 comments on commit 1e7622d

Please sign in to comment.