def format_exe_info(exeinfo, format="text", indlevel=0):
    """
    Generates listing of all Python scripts available as command-line programs.

    Args:
      exeinfo -- list of ExeInfo objects

      format -- One of the options below:
        "text" -- generates plain text for printing at the console
        "markdown-list" -- generates MarkDown as list
        "markdown-table" -- generates MarkDown as tables
        "rest-list" -- generates reStructuredText as lists

      indents -- indentation level ("text" format only)

    Returns: (list of strings, maximum filename size)
      list of strings -- can be joined with a "\n"
      maximum filename size
    """

    py_len = max([len(si.filename) for si in exeinfo])

    sisi_gra = [si for si in exeinfo if si.flag_gui == True]
    sisi_cmd = [si for si in exeinfo if si.flag_gui == False]
    sisi_none = [si for si in exeinfo if si.flag_gui is None]

    def get_title(x):
        return format_h4(x, format, indlevel*NIND) + [""]

    ret = []
    if len(sisi_gra) > 0:
        ret.extend(get_title("Graphical applications"))
        ret.extend(_format_exe_info(py_len, sisi_gra, format, indlevel + 1))
    if len(sisi_cmd) > 0:
        ret.extend(get_title("Command-line tools", ))
        ret.extend(_format_exe_info(py_len, sisi_cmd, format, indlevel + 1))
    if len(sisi_none) > 0:
        ret.extend(_format_exe_info(py_len, sisi_none, format, indlevel + 1))

    return ret, py_len
Generates listing of all Python scripts available as command-line programs.

    Args:
      exeinfo -- list of ExeInfo objects

      format -- One of the options below:
        "text" -- generates plain text for printing at the console
        "markdown-list" -- generates MarkDown as list
        "markdown-table" -- generates MarkDown as tables
        "rest-list" -- generates reStructuredText as lists

      indents -- indentation level ("text" format only)

    Returns: (list of strings, maximum filename size)
      list of strings -- can be joined with a "\n"
      maximum filename size