<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def list_themes(cls, path=THEMES):
 """ Compile all of the themes configuration files in the search path. """

        themes, errors = [], OrderedDict()

        def load_themes(path, source):
            """
            Load all themes in the given path.
            """
            if os.path.isdir(path):
                for filename in sorted(os.listdir(path)):
                    if not filename.endswith('.cfg'):
                        continue

                    filepath = os.path.join(path, filename)
                    name = filename[:-4]
                    try:
                        # Make sure the theme is valid
                        theme = cls.from_file(filepath, source)
                    except Exception as e:
                        errors[(source, name)] = e
                    else:
                        themes.append(theme)

        themes.extend([Theme(use_color=True), Theme(use_color=False)])
        load_themes(DEFAULT_THEMES, 'preset')
        load_themes(path, 'installed')

        return themes, errors