Decode OP_RETURN message from vout[1]
968420
def read_tx_opreturn(vout: dict) -> bytes:
    ''''''

    asm = vout['scriptPubKey']['asm']
    n = asm.find('OP_RETURN')
    if n == -1:
        raise InvalidNulldataOutput({'error': 'OP_RETURN not found.'})
    else:
        # add 10 because 'OP_RETURN ' is 10 characters
        n += 10
        data = asm[n:]
        n = data.find(' ')
        # make sure that we don't include trailing opcodes
        if n == -1:
            return bytes.fromhex(data)
        else:
            return bytes.fromhex(data[:n])
540217
def decodeRPCErrorMsg(e):
    
    found = re.search(
        (
            "(10 assert_exception: Assert Exception\n|"
            "3030000 tx_missing_posting_auth)"
            ".*: (.*)\n"
        ),
        str(e),
        flags=re.M,
    )
    if found:
        return found.group(2).strip()
    else:
        return str(e)
1183899
def _st_decode(self, msg):
        """"""
        group = int(msg[4:5])
        temperature = int(msg[7:10])
        if group == 0:
            temperature -= 60
        elif group == 1:
            temperature -= 40
        return {'group': group, 'device': int(msg[5:7])-1,
                'temperature': temperature}
711203
def opcode(*opcodes):
    """"""
    def decorator(func):
        setattr(func, "_is_opcode", True)
        setattr(func, "_opcodes", opcodes)
        return func
    return decorator
1168130
def decode_response(client_message, to_object=None):
    
    parameters = dict(response=None)
    if not client_message.read_bool():
        parameters['response'] = EntryViewCodec.decode(client_message, to_object)
    return parameters
761883
def decode(cls, command_str):
        

        name, _, arg = command_str.partition(" ")

        args = []

        if len(arg) > 0:
            if arg[0] != '{' or arg[-1] != '}':
                raise DataError("Invalid command, argument is not contained in { and }", arg=arg, cmd=name)

            arg = arg[1:-1]
            args = arg.split(",")

        proc = []

        for arg in args:
            if arg.startswith("hex:"):
                arg = unhexlify(arg[4:]).decode('utf-8')

            proc.append(arg)

        return Command(name, proc)
341880
def oper(inst):
    
    i = inst.strip(' \t\n').split(' ')
    I = i[0].lower()  # Instruction
    i = ''.join(i[1:])

    op = i.split(',')
    if I in {'call', 'jp', 'jr'} and len(op) > 1:
        op = op[1:] + ['f']

    elif I == 'djnz':
        op.append('b')

    elif I in {'push', 'pop', 'call'}:
        op.append('sp')  # Sp is also affected by push, pop and call

    elif I in {'or', 'and', 'xor', 'neg', 'cpl', 'rrca', 'rlca'}:
        op.append('a')

    elif I in {'rra', 'rla'}:
        op.extend(['a', 'f'])

    elif I in ('rr', 'rl'):
        op.append('f')

    elif I in {'adc', 'sbc'}:
        if len(op) == 1:
            op = ['a', 'f'] + op

    elif I in {'add', 'sub'}:
        if len(op) == 1:
            op = ['a'] + op

    elif I in {'ldd', 'ldi', 'lddr', 'ldir'}:
        op = ['hl', 'de', 'bc']

    elif I in {'cpd', 'cpi', 'cpdr', 'cpir'}:
        op = ['a', 'hl', 'bc']

    elif I == 'exx':
        op = ['*', 'bc', 'de', 'hl', 'b', 'c', 'd', 'e', 'h', 'l']

    elif I in {'ret', 'reti', 'retn'}:
        op += ['sp']

    elif I == 'out':
        if len(op) and RE_OUTC.match(op[0]):
            op[0] = 'c'
        else:
            op.pop(0)

    elif I == 'in':
        if len(op) > 1 and RE_OUTC.match(op[1]):
            op[1] = 'c'
        else:
            op.pop(1)

    for i in range(len(op)):
        tmp = RE_INDIR16.match(op[i])
        if tmp is not None:
            op[i] = '(' + op[i].strip()[1:-1].strip().lower() + ')'  # '  (  dE )  ' => '(de)'

    return op
1250671
function decode_operand(di, machine_code, offset=0) {
  const addressing_mode = di.addressing_mode;
  let consumed = 0;
  let value;

  switch(di.addressing_mode) {
    // 2-tryte operands
    case ADDR_MODE.INDIRECT_INDEXED_Y:
    case ADDR_MODE.INDEXED_X_INDIRECT:
    case ADDR_MODE.ABSOLUTE:
    case ADDR_MODE.ABSOLUTE_X:
    case ADDR_MODE.ABSOLUTE_Y:
    case ADDR_MODE.INDIRECT:
      value = machine_code[offset + 1];
      value += T_TO_TRITS_PER_TRYTE * machine_code[offset + 2];
      consumed = 2;
      break;

    // accumulator, register, no arguments
    case ADDR_MODE.ACCUMULATOR:
      consumed = 0;
      break;

    // immediate, 1-tryte literal
    case ADDR_MODE.IMMEDIATE:
      value = machine_code[offset + 1];
      consumed = 1;
      break;
  }

  return {addressing_mode, value, consumed};
}
1265799
def op_extract(op_name, data, senders, inputs, outputs, block_id, vtxindex, txid):
    
    global EXTRACT_METHODS

    if op_name not in EXTRACT_METHODS.keys():
        raise Exception("No such operation '%s'" % op_name)

    method = EXTRACT_METHODS[op_name]
    op_data = method( data, senders, inputs, outputs, block_id, vtxindex, txid )
    return op_data
613427
def fix_opcode_names(opmap):
    
    return dict([(k.replace('+', '_'), v)
                  for (k, v) in opmap.items()])
485182
def convert_op(self, op):
        

        if op == '.gt.':
            return '>'
        elif op == '.ge.' or op == '.geq.':
            return '>='
        elif op == '.lt.':
            return '<'
        elif op == '.le.':
            return '<='
        elif op == '.eq.':
            return '=='
        elif op == '.neq.':   
            return '!='
        elif op == '.ne.':   # .neq. is preferred!
            return '!='
        elif op == '^':
            return '**'
        elif op == '.and.':
            return 'and'
        elif op == '.or.':
            return 'or'
        else:
            return op
276971
def decode(dinfo, cio):
    
    argtypes = [ctypes.POINTER(DecompressionInfoType), ctypes.POINTER(CioType)]
    OPENJPEG.opj_decode.argtypes = argtypes
    OPENJPEG.opj_decode.restype = ctypes.POINTER(ImageType)
    image = OPENJPEG.opj_decode(dinfo, cio)
    return image
529831
def decode(cls, encoded):
        
        def create_dict(items):
            # Let's guarantee that dictionaries are sorted.
            k_v_pair = zip(*[iter(items)] * 2)
            return OrderedDict(sorted(k_v_pair, key=itemgetter(0)))

        def create_list(items):
            return list(items)

        stack_items = []
        stack_containers = []

        def compress_stack():
            target_container = stack_containers.pop()
            subitems = []

            while True:
                subitem = stack_items.pop()
                subitems.append(subitem)
                if subitem is target_container:
                    break

            container_creator = subitems.pop()
            container = container_creator(reversed(subitems))
            stack_items.append(container)

        def parse_forward(till_char, sequence):
            number = ''
            char_sub_idx = 0

            for char_sub_idx, char_sub in enumerate(sequence):
                char_sub = chr_(char_sub)
                if char_sub == till_char:
                    break

                number += char_sub

            number = int(number or 0)
            char_sub_idx += 1

            return number, char_sub_idx

        while encoded:
            char = encoded[0]
            char = chr_(char)

            if char == 'd':  # Dictionary
                stack_items.append(create_dict)
                stack_containers.append(create_dict)
                encoded = encoded[1:]

            elif char == 'l':  # List
                stack_items.append(create_list)
                stack_containers.append(create_list)
                encoded = encoded[1:]

            elif char == 'i':  # Integer
                number, char_sub_idx = parse_forward('e', encoded[1:])
                char_sub_idx += 1

                stack_items.append(number)
                encoded = encoded[char_sub_idx:]

            elif char.isdigit():  # String
                str_len, char_sub_idx = parse_forward(':', encoded)
                last_char_idx = char_sub_idx + str_len

                string = encoded[char_sub_idx:last_char_idx]
                try:
                    string = string.decode('utf-8')
                except UnicodeDecodeError:
                    # Considered bytestring (e.g. `pieces` hashes concatenation).
                    pass

                stack_items.append(string)
                encoded = encoded[last_char_idx:]

            elif char == 'e':  # End of a dictionary or a list.
                compress_stack()
                encoded = encoded[1:]

            else:
                raise BencodeDecodingError('Unable to interpret `%s` char.' % char)

        if len(stack_items) == 1:
            stack_items = stack_items.pop()

        return stack_items
816913
def op_at_code_loc(code, loc, opc):
    
    try:
        op = code[loc]
    except IndexError:
        return 'got IndexError'
    return opc.opname[op]
1004236
def _decode_num(buf):
    
    return functools.reduce(lambda acc, val: acc * 256 + tds_base.my_ord(val), reversed(buf), 0)
627266
function decode(msg) {
  const len = msg.length;
  if (len > 0) {
    const c = msg.charCodeAt(len - 1);
    if (c >= 1 && c <= 8) {
      const provided = msg.substr(len - c);
      const computed = String.fromCharCode(c).repeat(c);
      if (provided === computed) {
        return msg.substr(0, len - c);
      }
    }
  }
  throw new Error('Invalid padding');
}
1180500
def make_op_return_script(data, format='bin'):
    
    if format == 'hex':
        assert(is_hex(data))
        hex_data = data
    elif format == 'bin':
        hex_data = hexlify(data)
    else:
        raise Exception("Format must be either 'hex' or 'bin'")

    num_bytes = count_bytes(hex_data)
    if num_bytes > MAX_BYTES_AFTER_OP_RETURN:
        raise Exception('Data is %i bytes - must not exceed 40.' % num_bytes)

    script_string = 'OP_RETURN %s' % hex_data
    return script_to_hex(script_string)