Skip to content
Snippets Groups Projects
Commit 8b483d00 authored by Holger Nahrstaedt's avatar Holger Nahrstaedt
Browse files

fix python 2.7 and remove not needed types

parent 225f39dc
No related branches found
No related tags found
No related merge requests found
......@@ -181,7 +181,7 @@ class Steem(object):
def is_connected(self):
"""Returns if rpc is connected"""
return bool(self.rpc)
return self.rpc is not None
def refresh_data(self, force_refresh=False, data_refresh_time_seconds=None):
"""
......
......@@ -386,78 +386,6 @@ class Id(object):
return str(self.data)
@python_2_unicode_compatible
class VoteId(object):
def __init__(self, vote):
parts = vote.split(":")
if not len(parts) == 2:
raise AssertionError()
self.type = int(parts[0])
self.instance = int(parts[1])
def __bytes__(self):
"""Returns bytes representation."""
binary = (self.type & 0xff) | (self.instance << 8)
return struct.pack("<I", binary)
def __str__(self):
"""Returns data as string."""
return "%d:%d" % (self.type, self.instance)
@python_2_unicode_compatible
class ObjectId(object):
""" Encodes protocol ids - serializes to the *instance* only!
"""
def __init__(self, object_str, type_verify=None):
if len(object_str.split(".")) == 3:
space, type, id = object_str.split(".")
self.space = int(space)
self.type = int(type)
self.instance = Id(int(id))
self.Id = object_str
if type_verify:
if not object_type[type_verify] == int(type):
raise AssertionError("Object id does not match object type! " +
"Excpected %d, got %d" % (object_type[type_verify], int(type)))
else:
raise Exception("Object id is invalid")
def __bytes__(self):
"""Returns bytes representation."""
return py23_bytes(self.instance) # only yield instance
def __str__(self):
"""Returns data as string."""
return self.Id
@python_2_unicode_compatible
class FullObjectId(object):
""" Encodes object ids - serializes to a full object id
"""
def __init__(self, object_str):
if len(object_str.split(".")) == 3:
space, type, id = object_str.split(".")
self.space = int(space)
self.type = int(type)
self.id = int(id)
self.instance = Id(int(id))
self.Id = object_str
else:
raise Exception("Object id is invalid")
def __bytes__(self):
"""Returns bytes representation."""
return (
self.space << 56 | self.type << 48 | self.id
).to_bytes(8, byteorder="little", signed=False)
def __str__(self):
"""Returns data as string."""
return self.Id
@python_2_unicode_compatible
class Enum8(Uint8):
def __init__(self, selection):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment