def _filter_unwanted_classes(self, items): """ And remove out any functions that match the filters. """ for filter in regex_from_str(self.name_filters, match_anywhere=False): items = [ a_class for a_class in items if filter.match(a_class.name) is None ] for filter in regex_from_str(self.module_filters, match_anywhere=False): items = [ a_class for a_class in items if filter.match(a_class.module) is None ] return items
def _move_leading_matches_to_front(self, items): """ Move classes that match at the beginning of the function name to the front of the list. The returned list is sorted alphabetically otherwise. """ # leading will hold these functions anditems will hold all the others. leading = [] filters = regex_from_str(self.search_term, match_anywhere=False) # iterate over a copy of the list because we are going to modify # the original in the loop. for a_class in items[:]: for filter in filters: if (self.search_name and filter.match(a_class.name) is not None): items.remove(a_class) leading.append(a_class) break # Sort the individual list. def cmp_name(x, y): """ Compare the name of the classes, ignoring case """ return cmp(x.name.lower(), y.name.lower()) # Now, reconstruct the list with leading functions first. result = sorted(leading, cmp=cmp_name) + sorted(items, cmp=cmp_name) return result
def _move_leading_matches_to_front(self, items): """ Move classes that match at the beginning of the function name to the front of the list. The returned list is sorted alphabetically otherwise. """ # leading will hold these functions anditems will hold all the others. leading = [] filters = regex_from_str(self.search_term, match_anywhere=False) # iterate over a copy of the list because we are going to modify # the original in the loop. for a_class in items[:]: for filter in filters: if (self.search_name and filter.match(a_class.name) is not None): items.remove(a_class) leading.append(a_class) break # Sort the individual list. def cmp_name(x,y): """ Compare the name of the classes, ignoring case """ return cmp(x.name.lower(), y.name.lower()) # Now, reconstruct the list with leading functions first. result = sorted(leading, cmp=cmp_name) + sorted(items, cmp=cmp_name) return result
def _match_anywhere(self): """ Match search term to class name and/or module name, by matching the search patterns anywhere within the strings. """ items = [] # First, match filters anywhere within function name and module. filters = regex_from_str(self.search_term, match_anywhere=True) for a_class in self.all_classes: for filter in filters: if (self.search_name and filter.match(a_class.name) is not None): items.append(a_class) break elif (self.search_module and filter.match(a_class.module) is not None): items.append(a_class) break return items