(name, value)
format the given value into something human readable, using the given name as a hint.

    Example::

        assert format_value('sections:11:payload_len', 0x23) == '0x23'

    Example::

        assert format_value('sections:1:payload:entries:0:param_types', [-1, -1, -1]) == '[i32, i32, i32]'

    Args:
      name (str): the structure property name.
      value (Any): the value to format.

    Returns:
      str: a string formatted for human consumption.
format the given value into something human readable, using the given name as a hint.
format the given value into something human readable using the given name as a hint .
def format_value(name, value):
    '''
    format the given value into something human readable, using the given name as a hint.

    Example::

        assert format_value('sections:11:payload_len', 0x23) == '0x23'

    Example::

        assert format_value('sections:1:payload:entries:0:param_types', [-1, -1, -1]) == '[i32, i32, i32]'

    Args:
      name (str): the structure property name.
      value (Any): the value to format.

    Returns:
      str: a string formatted for human consumption.
    '''
    if isinstance(value, int):
        # a heuristic to detect fields that contain a type value
        if 'type' in name or 'form' in name:
            try:
                return idawasm.const.WASM_TYPE_NAMES[value]
            except KeyError:
                return hex(value)
        else:
            return hex(value)
    elif isinstance(value, list):
        return '[' + ', '.join([format_value(name, v) for v in value]) + ']'
    elif isinstance(value, memoryview) and 'str' in name:
        try:
            return value.tobytes().decode('utf-8')
        except UnicodeDecodeError:
            return ''
    else:
        return ''
def format_value ( name , value ) : if isinstance ( value , int ) : # a heuristic to detect fields that contain a type value if 'type' in name or 'form' in name : try : return idawasm . const . WASM_TYPE_NAMES [ value ] except KeyError : return hex ( value ) else : return hex ( value ) elif isinstance ( value , list ) : return '[' + ', ' . join ( [ format_value ( name , v ) for v in value ] ) + ']' elif isinstance ( value , memoryview ) and 'str' in name : try : return value . tobytes ( ) . decode ( 'utf-8' ) except UnicodeDecodeError : return '' else : return ''