コード例 #1
0
def read_tags(reader: MemoryViewReader) -> Iterable[Tag]:
    """
    Read tags from the stream and get an iterable of tags.
    """
    while not reader.is_eof():
        code_length = reader.read_u16()
        length = code_length & 0b111111
        if length == 0x3F:
            # Long tag header.
            length = reader.read_u32()
        try:
            type_ = TagType(code_length >> 6)
        except ValueError:
            # Unknown tag type. Skip the tag.
            reader.skip(length)
        else:
            yield Tag(type_=type_, raw=reader.read(length))
コード例 #2
0
 def __init__(self, raw: memoryview):
     reader = MemoryViewReader(raw)
     self.flags = DoABCTagFlags(reader.read_u32())
     self.name = reader.read_string()
     self.abc_file = reader.read_all()