2018-03-21 06:59:04 +07:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-03-24 06:44:00 +07:00
|
|
|
from struct import pack #, unpack
|
2018-04-28 07:00:13 +07:00
|
|
|
import codecs
|
2018-03-21 06:59:04 +07:00
|
|
|
class Finger(object):
|
|
|
|
def __init__(self, size, uid, fid, valid, template):
|
2018-04-07 07:01:35 +07:00
|
|
|
self.size = size # template only
|
2018-03-21 06:59:04 +07:00
|
|
|
self.uid = uid
|
|
|
|
self.fid = fid
|
|
|
|
self.valid = valid
|
|
|
|
self.template = template
|
2018-04-28 07:00:13 +07:00
|
|
|
#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)
|
2018-03-21 06:59:04 +07:00
|
|
|
|
|
|
|
def __str__(self):
|
2018-04-30 21:25:43 +07:00
|
|
|
return "<Finger> [uid:%i, fid:%i, size:%i v:%i t:%s...]" % (self.uid, self.fid, self.size, self.valid, self.mark)
|
2018-03-21 06:59:04 +07:00
|
|
|
|
|
|
|
def __repr__(self):
|
2018-04-30 21:25:43 +07:00
|
|
|
return "<Finger> [uid:%i, fid:%i, size:%i v:%i t:%s...]" % (self.uid, self.fid, self.size, self.valid, self.mark) #.encode('hex')
|