def parse_property(data: dict) -> dict: prop = {} prop[0x1a] = gls.CHARSET[util.unpack_ui(bytes(data[0x1a]))] prop[0x1b] = gls.CHARSET[util.unpack_ui(bytes(data[0x1b]))] for prop_id in [gls.P_TITLE, gls.P_AUTHOR_NAME, gls.P_AUTHOR_EMAIL]: prop[prop_id] = bytes(data[prop_id]).decode('latin1') for prop_id in [gls.P_ICON, gls.P_MANUAL]: prop[prop_id] = data[prop_id] return prop
def parse_property(data:dict)->dict: prop={} prop[0x1a]=gls.CHARSET[util.unpack_ui(bytes(data[0x1a]))] prop[0x1b]=gls.CHARSET[util.unpack_ui(bytes(data[0x1b]))] for prop_id in [ gls.P_TITLE, gls.P_AUTHOR_NAME, gls.P_AUTHOR_EMAIL ]: prop[prop_id]=bytes(data[prop_id]).decode('latin1') for prop_id in [ gls.P_ICON, gls.P_MANUAL]: prop[prop_id]=data[prop_id] return prop
def unpack_property(data:memoryview) -> (int,memoryview): return (util.unpack_ui(bytes(data[0:2])),data[2:])
def unpack_block(data:memoryview,x:int)-> (memoryview,memoryview): """return a tuple (block_data,unprocessed)""" blk_len=util.unpack_ui(bytes(data[0:x])) return (data[x:x+blk_len],data[x+blk_len:])
def unpack_property(data: memoryview) -> (int, memoryview): return (util.unpack_ui(bytes(data[0:2])), data[2:])
def unpack_block(data: memoryview, x: int) -> (memoryview, memoryview): """return a tuple (block_data,unprocessed)""" blk_len = util.unpack_ui(bytes(data[0:x])) return (data[x:x + blk_len], data[x + blk_len:])