# -*- coding: utf-8 -*- from struct import pack #, unpack class User(object): encoding = 'UTF-8' def __init__(self, uid, name, privilege, password='', group_id='', user_id='', card=0): self.uid = uid self.name = u'{0}'.format(name) self.privilege = privilege self.password = str(password) self.group_id = str(group_id) self.user_id = user_id self.card = int(card) # 64 int to 40 bit int @staticmethod def json_unpack(json): #validate? return User( uid=json['uid'], name=json['name'], privilege=json['privilege'], password=json['password'], group_id=json['group_id'], user_id=json['user_id'], card=json['card'] ) def repack29(self): # with 02 for zk6 (size 29) return pack(" 7sx group id, timezone? return pack(": [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id) def __repr__(self): return ': [uid:{}, name:{} user_id:{}]'.format(self.uid, self.name, self.user_id)