Пример #1
0
def parse(script):
    f = script, 0
    while pack.size(f):
        opcode_str, f = pack.read(f, 1)
        opcode = ord(opcode_str)
        opcode_name, read_func = opcodes[opcode]
        opcode_arg, f = read_func(f)
        yield opcode_name, opcode_arg
Пример #2
0
def parse(script):
    f = script, 0
    while pack.size(f):
        opcode_str, f = pack.read(f, 1)
        opcode = ord(opcode_str)
        opcode_name, read_func = opcodes[opcode]
        opcode_arg, f = read_func(f)
        yield opcode_name, opcode_arg
Пример #3
0
    def read(self, file):
        obj, file = self.inner.read(file)
        data = self.inner.pack(obj)

        calculated_checksum = self.checksum_func(data)
        checksum, file = pack.read(file, len(calculated_checksum))
        if checksum != calculated_checksum:
            raise ValueError('invalid checksum')

        return obj, file
Пример #4
0
    def read(self, file):
        obj, file = self.inner.read(file)
        data = self.inner.pack(obj)

        calculated_checksum = self.checksum_func(data)
        checksum, file = pack.read(file, len(calculated_checksum))
        if checksum != calculated_checksum:
            raise ValueError('invalid checksum')

        return obj, file
Пример #5
0
def protoPUSH(length):
    return lambda f: pack.read(f, length)
Пример #6
0
 def _(f):
     length_str, f = pack.read(f, size_len)
     length = math.string_to_natural(length_str[::-1].lstrip(chr(0)))
     data, f = pack.read(f, length)
     return data, f
Пример #7
0
 def _(f):
     length_str, f = pack.read(f, size_len)
     length = math.string_to_natural(length_str[::-1].lstrip(chr(0)))
     data, f = pack.read(f, length)
     return data, f
Пример #8
0
def protoPUSH(length):
    return lambda f: pack.read(f, length)