pyztk/zk/finger.py

24 lines
947 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
from struct import pack #, unpack
import codecs
class Finger(object):
def __init__(self, size, uid, fid, valid, template):
2018-04-07 07:01:35 +07:00
self.size = size # template only
self.uid = uid
self.fid = fid
self.valid = valid
self.template = template
#self.mark = str().encode("hex")
self.mark = codecs.encode(template[:6], 'hex')
2018-04-07 07:01:35 +07:00
def repack(self): #full
return pack("HHbb%is" % (self.size), self.size+6, self.uid, self.fid, self.valid, self.template)
def repack_only(self): #only template
return pack("H%is" % (self.size), self.size+2, self.template)
def __str__(self):
2018-03-28 06:32:56 +07:00
return "<Finger> [u:%i, fid:%i, size:%i v:%i t:%s...]" % (self.uid, self.fid, self.size, self.valid, self.mark)
def __repr__(self):
2018-03-28 06:32:56 +07:00
return "<Finger> [u:%i, fid:%i, size:%i v:%i t:%s...]" % (self.uid, self.fid, self.size, self.valid, self.mark) #.encode('hex')