def fetch_and_prepare(self): """ Uses AMICleaner to retrieve candidates AMI, map and reduce """ cleaner = AMICleaner() mapped_amis = cleaner.map_candidates( mapping_strategy=self.mapping_strategy) if not mapped_amis: return None candidates = [] report = dict() for group_name, amis in mapped_amis.iteritems(): group_name = group_name or "" if not group_name: report["no-tags (excluded)"] = amis else: reduced = cleaner.reduce_candidates(amis, self.keep_previous) if reduced: report[group_name] = reduced candidates.extend(reduced) Printer.print_report(report, self.full_report) return candidates
def prepare_candidates(self, candidates_amis=None): """ From an AMI list apply mapping strategy and filters """ candidates_amis = candidates_amis or self.fetch_candidates() if not candidates_amis: return None c = AMICleaner() mapped_amis = c.map_candidates( candidates_amis=candidates_amis, mapping_strategy=self.mapping_strategy, ) if not mapped_amis: return None candidates = [] report = dict() for group_name, amis in mapped_amis.iteritems(): group_name = group_name or "" if not group_name: report["no-tags (excluded)"] = amis else: reduced = c.reduce_candidates(amis, self.keep_previous) if reduced: report[group_name] = reduced candidates.extend(reduced) Printer.print_report(report, self.full_report) return candidates