cleanup code

This commit is contained in:
Fanani M. Ihsan 2018-12-27 13:57:49 +07:00
parent 0d04f61e1f
commit e4b229886e
3 changed files with 308 additions and 369 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,10 @@ class ZKError(Exception):
pass
class ZKErrorConnection(ZKError):
pass
class ZKErrorResponse(ZKError):
pass

View File

@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
from struct import pack #, unpack
import codecs
class Finger(object):
def __init__(self, uid, fid, valid, template):
self.size = len(template) # template only
self.uid = int(uid)
@ -16,6 +19,7 @@ class Finger(object):
def repack_only(self): #only template
return pack("H%is" % (self.size), self.size, self.template)
@staticmethod
def json_unpack(json):
return Finger(
@ -24,6 +28,7 @@ class Finger(object):
valid=json['valid'],
template=codecs.decode(json['template'],'hex')
)
def json_pack(self): #packs for json
return {
"size": self.size,
@ -44,3 +49,4 @@ class Finger(object):
def dump(self):
return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, codecs.encode(self.template, 'hex'))