def _filter_sources(self, sources):
        """Remove sources with errors and return ordered by host success.

        :param sources: List of potential sources to connect to.
        :type sources: list
        :returns: Sorted list of potential sources without errors.
        :rtype: list
        """
        filtered, hosts = [], []
        for source in sources:
            if 'error' in source:
                continue
            filtered.append(source)
            hosts.append(source['host_name'])

        return sorted(filtered, key=lambda s:
                      self._hosts_by_success(hosts).index(s['host_name']))
def _filter_sources ( self , sources ) : filtered , hosts = [ ] , [ ] for source in sources : if 'error' in source : continue filtered . append ( source ) hosts . append ( source [ 'host_name' ] ) return sorted ( filtered , key = lambda s : self . _hosts_by_success ( hosts ) . index ( s [ 'host_name' ] ) )
Remove sources with errors and return ordered by host success.

        :param sources: List of potential sources to connect to.
        :type sources: list
        :returns: Sorted list of potential sources without errors.
        :rtype: list