now compatible with Python >=3.5

This commit is contained in:
ahmadbilalkhalid 2019-09-12 13:49:06 +05:00
parent 25cfb3c80d
commit db26ec5d1f
3 changed files with 5 additions and 10 deletions

View file

@ -1,2 +1,2 @@
from .etcd3_wrapper import Etcd3Wrapper, EtcdEntry from etcd3_wrapper import Etcd3Wrapper, EtcdEntry
name = "etcd3_wrapper" name = "etcd3_wrapper"

View file

@ -4,25 +4,20 @@ import queue
import copy import copy
from collections import namedtuple from collections import namedtuple
from dataclasses import dataclass
PseudoEtcdMeta = namedtuple("PseudoEtcdMeta", ["key"]) PseudoEtcdMeta = namedtuple("PseudoEtcdMeta", ["key"])
@dataclass(init=False)
class EtcdEntry: class EtcdEntry:
key: str # key: str
value: str # value: str
def __init__(self, meta, value, value_in_json=False): def __init__(self, meta, value, value_in_json=False):
self.key = meta.key.decode("utf-8") self.key = meta.key.decode("utf-8")
self.value = value.decode("utf-8") self.value = value.decode("utf-8")
if value_in_json: if value_in_json:
try:
self.value = json.loads(self.value) self.value = json.loads(self.value)
except json.JSONDecodeError as e:
print(f"Json Error: {e}, value={value}")
class Etcd3Wrapper: class Etcd3Wrapper:

View file

@ -19,5 +19,5 @@ setuptools.setup(
classifiers=[ classifiers=[
'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3',
], ],
python_requires='>=3.6', python_requires='>=3.5',
) )