cleanup code
This commit is contained in:
parent
0d04f61e1f
commit
e4b229886e
667
zk/base.py
667
zk/base.py
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,10 @@ class ZKError(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ZKErrorConnection(ZKError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ZKErrorResponse(ZKError):
|
class ZKErrorResponse(ZKError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from struct import pack #, unpack
|
from struct import pack #, unpack
|
||||||
import codecs
|
import codecs
|
||||||
|
|
||||||
|
|
||||||
class Finger(object):
|
class Finger(object):
|
||||||
|
|
||||||
def __init__(self, uid, fid, valid, template):
|
def __init__(self, uid, fid, valid, template):
|
||||||
self.size = len(template) # template only
|
self.size = len(template) # template only
|
||||||
self.uid = int(uid)
|
self.uid = int(uid)
|
||||||
@ -16,6 +19,7 @@ class Finger(object):
|
|||||||
|
|
||||||
def repack_only(self): #only template
|
def repack_only(self): #only template
|
||||||
return pack("H%is" % (self.size), self.size, self.template)
|
return pack("H%is" % (self.size), self.size, self.template)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def json_unpack(json):
|
def json_unpack(json):
|
||||||
return Finger(
|
return Finger(
|
||||||
@ -24,6 +28,7 @@ class Finger(object):
|
|||||||
valid=json['valid'],
|
valid=json['valid'],
|
||||||
template=codecs.decode(json['template'],'hex')
|
template=codecs.decode(json['template'],'hex')
|
||||||
)
|
)
|
||||||
|
|
||||||
def json_pack(self): #packs for json
|
def json_pack(self): #packs for json
|
||||||
return {
|
return {
|
||||||
"size": self.size,
|
"size": self.size,
|
||||||
@ -44,3 +49,4 @@ class Finger(object):
|
|||||||
|
|
||||||
def dump(self):
|
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'))
|
return "<Finger> [uid:{:>3}, fid:{}, size:{:>4} v:{} t:{}]".format(self.uid, self.fid, self.size, self.valid, codecs.encode(self.template, 'hex'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user