import logging import struct from extract_msg import constants from extract_msg.utils import divide # , round_up logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) # TODO move this function to utils.py: def round_up(inp, mult): """ Rounds :param inp: up to the nearest multiple of :param mult:. """ return inp + (mult - inp) % mult # Temporary class code to make references like `constants.CONSTANT` work: class constants(object): # Structs used by named.py STNP_NAM = struct.Struct('> 1, 'pkind': tmp[1] & 1, }) names = [] pos = 0 while pos < nl: l = constants.STNP_NAM.unpack(names_stream[pos:pos + 4])[0] pos += 4 names.append(names_stream[pos:pos + l].decode('utf_16_le')) pos += round_up(l, 4)