Ejemplo n.º 1
0
    def _read(self, stream: Stream, version):
        number_layers = stream.read_uint('layer count')
        for i in range(number_layers):
            layer = stream.read_object('symbol layer {}/{}'.format(
                i + 1, number_layers))
            self.levels.extend([layer])

        # the next section varies in size. To handle this we jump forward to a known anchor
        # point, and then move back by a known amount

        # burn up to the 02
        stream.log('burning up to 02...')
        while not binascii.hexlify(stream.read(1)) == b'02':
            pass

        # jump back a known amount
        stream.rewind(8 * number_layers + 1)

        # TODO - replace the fragile bit above!
        #   stream.read(1)

        #   stream.read_double('unknown size')
        #   stream.read_double('unknown size')

        for l in self.levels:
            l.read_enabled(stream)
        for l in self.levels:
            l.read_locked(stream)
Ejemplo n.º 2
0
    def _read(self, stream: Stream, version):
        self.color = stream.read_object('color')

        number_layers = stream.read_int('layers')
        for i in range(number_layers):
            stream.consume_padding()
            layer = stream.read_object('symbol layer {}/{}'.format(
                i + 1, number_layers))
            self.levels.extend([layer])

        # the next section varies in size. To handle this we jump forward to a known anchor
        # point, and then move back by a known amount

        # burn up to the 02
        stream.log('burning up to 02...')
        while not binascii.hexlify(stream.read(1)) == b'02':
            pass

        # jump back a known amount
        stream.rewind(8 * number_layers + 1)

        for l in self.levels:
            l.read_enabled(stream)
        for l in self.levels:
            l.read_locked(stream)
Ejemplo n.º 3
0
    def read(self, stream: Stream, version):
        stream.read(8)
        self._read(stream, version)
        # do we end in 02?
        check = binascii.hexlify(stream.read(1))
        if check != b'02':
            raise UnreadableSymbolException(
                'Found unexpected value {} at {}, expected x02'.format(
                    check, hex(stream.tell() - 1)))
        stream.read(5)

        # PROBLEMATIC!!

        check = binascii.hexlify(stream.read(1))
        if check == b'02':
            stream.read(5)
        else:
            stream.rewind(1)