Exemplo n.º 1
0
 def _repr_pretty_(self, p, cycle):
     if cycle:
         p.text(repr(self))
     else:
         with p.group(0, 'Block(', ')'):
             p.text("%s %s, " % (self.key, TaggedBlock.name_of(self.key)))
             if isinstance(self.data, bytes):
                 p.text(trimmed_repr(self.data))
             else:
                 p.pretty(self.data)
Exemplo n.º 2
0
 def _repr_pretty_(self, p, cycle):
     if cycle:
         p.text('Block(...)')
     else:
         with p.group(1, 'Block(', ')'):
             p.breakable()
             p.text("%s %s," % (self.key, TaggedBlock.name_of(self.key)))
             p.breakable()
             if isinstance(self.data, bytes):
                 p.text(trimmed_repr(self.data))
             else:
                 p.pretty(self.data)
Exemplo n.º 3
0
def _read_additional_layer_info_block(fp, padding):
    """
    Reads a tagged block with additional layer information.
    """
    sig = fp.read(4)
    if sig not in (b'8BIM', b'8B64'):
        raise Error("Invalid signature of tagged block (%r)" % sig)

    key = fp.read(4)
    length = read_fmt("I", fp)[0]
    if not length:
        logger.debug(
            "Found tagged block with no data (%s %s). Dropping..." % (
            key, TaggedBlock.name_of(key)
        ))
        return None

    if padding > 0:
        length = pad(length, padding)

    data = fp.read(length)
    return Block(key, data)
Exemplo n.º 4
0
 def __repr__(self):
     return "Block(%s %s, %s)" % (self.key, TaggedBlock.name_of(self.key),
                                  trimmed_repr(self.data))
Exemplo n.º 5
0
 def __repr__(self):
     return "Block(%s %s, %s)" % (self.key, TaggedBlock.name_of(
         self.key), trimmed_repr(self.data))