(lst, key="key", val="text", indent=0)
return ret
Format a list of (key, value) tuples.

        If key is None, it's treated specially:
            - We assume a sub-value, and add an extra indent.
            - The value is treated as a pre-formatted list of directives.
Format a list of (key, value) tuples.
Format a list of ( key value ) tuples .
def format_keyvals(lst, key="key", val="text", indent=0):
    """
        Format a list of (key, value) tuples.

        If key is None, it's treated specially:
            - We assume a sub-value, and add an extra indent.
            - The value is treated as a pre-formatted list of directives.
    """
    ret = []
    if lst:
        maxk = min(max(len(i[0]) for i in lst if i and i[0]), KEY_MAX)
        for i, kv in enumerate(lst):
            if kv is None:
                ret.append(urwid.Text(""))
            else:
                cols = []
                # This cumbersome construction process is here for a reason:
                # Urwid < 1.0 barfs if given a fixed size column of size zero.
                if indent:
                    cols.append(("fixed", indent, urwid.Text("")))
                cols.extend([
                    (
                        "fixed",
                        maxk,
                        urwid.Text([(key, kv[0] or "")])
                    ),
                    kv[1] if isinstance(kv[1], urwid.Widget) else urwid.Text([(val, kv[1])])
               ])
                ret.append(urwid.Columns(cols, dividechars = 2))
    return ret
def format_keyvals ( lst , key = "key" , val = "text" , indent = 0 ) : ret = [ ] if lst : maxk = min ( max ( len ( i [ 0 ] ) for i in lst if i and i [ 0 ] ) , KEY_MAX ) for i , kv in enumerate ( lst ) : if kv is None : ret . append ( urwid . Text ( "" ) ) else : cols = [ ] # This cumbersome construction process is here for a reason: # Urwid < 1.0 barfs if given a fixed size column of size zero. if indent : cols . append ( ( "fixed" , indent , urwid . Text ( "" ) ) ) cols . extend ( [ ( "fixed" , maxk , urwid . Text ( [ ( key , kv [ 0 ] or "" ) ] ) ) , kv [ 1 ] if isinstance ( kv [ 1 ] , urwid . Widget ) else urwid . Text ( [ ( val , kv [ 1 ] ) ] ) ] ) ret . append ( urwid . Columns ( cols , dividechars = 2 ) ) return ret