def get_list_of_all_supported_commands(config):
    """
    Generate a list of all the commands that have examples known to eg. The
    format of the list is the command names. The fact that there are examples
    for 'cp', for example, would mean that 'cp' was in the list.

    The format of the list contains additional information to say if there are
    only default examples, only custom examples, or both:

        cp    (only default)
        cp *  (only custom)
        cp +  (default and custom)

    Aliases are shown as
    alias -> resolved, with resolved having its '*' or '+' as expected. Aliases
    that shadow custom-only file names are expected to be shown instead of the
    custom file names. This is intentional, as that is the behavior for file
    resolution--an alias will hide a custom file.
    """
    default_files = []
    custom_files = []

    if config.examples_dir and os.path.isdir(config.examples_dir):
        default_files = os.listdir(config.examples_dir)
    if config.custom_dir and os.path.isdir(config.custom_dir):
        custom_files = os.listdir(config.custom_dir)

    # Now filter so we only have example files, not things like aliases.json.
    default_files = [path for path in default_files if _is_example_file(path)]
    custom_files = [path for path in custom_files if _is_example_file(path)]

    def get_without_suffix(file_name):
        """
        Return the file name without the suffix, or the file name itself
        if it does not have the suffix.
        """
        return file_name.split(EXAMPLE_FILE_SUFFIX)[0]

    default_files = [get_without_suffix(f) for f in default_files]
    custom_files = [get_without_suffix(f) for f in custom_files]

    set_default_commands = set(default_files)
    set_custom_commands = set(custom_files)

    alias_dict = get_alias_dict(config)

    both_defined = set_default_commands & set_custom_commands
    only_default = set_default_commands - set_custom_commands
    only_custom = set_custom_commands - set_default_commands

    all_commands = both_defined | only_default | only_custom

    command_to_rep = {}
    for command in all_commands:
        rep = None
        if command in both_defined:
            rep = command + ' ' + FLAG_CUSTOM_AND_DEFAULT
        elif command in only_default:
            rep = command
        elif command in only_custom:
            rep = command + ' ' + FLAG_ONLY_CUSTOM
        else:
            raise NameError('command not in known set: ' + str(command))
        command_to_rep[command] = rep

    result = []
    all_commands_and_aliases = all_commands.union(alias_dict.keys())
    for command in all_commands_and_aliases:
        if command in alias_dict:
            # aliases get precedence
            target = alias_dict[command]
            rep_of_target = command_to_rep[target]
            result.append(command + ' -> ' + rep_of_target)
        else:
            rep = command_to_rep[command]
            result.append(rep)

    result.sort()
    return result
dataset/ETHPy150Open srsudar/eg/eg/util.py/get_list_of_all_supported_commands/original