def beautify_similar_files(self, similar_files, fo_list, similarity): result_dict = {} for match in similar_files: match_dict = self._get_empty_match_dict(fo_list) for file in match: firm, sub = file.split(':') match_dict[firm] = sub if list_to_unified_string_list(match) in similarity.keys(): match_dict['similarity'] = similarity[list_to_unified_string_list(match)] else: match_dict['similarity'] = '' result_dict[self._match_id(match)] = match_dict return result_dict
def _calculate_compare_result_id(compare_result): general_dict = compare_result['general'] uid_set = set() for key in general_dict: uid_set.update(list(general_dict[key].keys())) comp_id = list_to_unified_string_list(list(uid_set)) return comp_id
def _get_similar_files(self, fo_list, exclusive_files): similars = list() similarity = dict() for index, _ in enumerate(fo_list): tmp_list = deepcopy(fo_list) parent_one = tmp_list.pop(index) for parent_two in tmp_list: for file_one in exclusive_files[parent_one.get_uid()]: for item, value in self._find_similar_file_for(file=file_one, parent_id=parent_one.get_uid(), potential_matches=parent_two): similars.append(item) similarity[list_to_unified_string_list(item)] = value similarity_sets = self.produce_similarity_sets(remove_duplicates_from_list_of_lists(similars)) remove_included_sets_from_list_of_sets(similarity_sets) return remove_duplicates_from_list_of_lists(list_of_sets_to_list_of_lists(similarity_sets)), similarity
def _app_show_start_compare(self): if 'uids_for_comparison' not in session or not isinstance(session['uids_for_comparison'], list) or len(session['uids_for_comparison']) < 2: return render_template('compare/error.html', error='No UIDs found for comparison') compare_id = list_to_unified_string_list(session['uids_for_comparison']) session['uids_for_comparison'] = None redo = True if request.args.get('force_recompare') else None with ConnectTo(CompareDbInterface, self._config) as sc: compare_exists = sc.compare_result_is_in_db(compare_id) if compare_exists and not redo: return redirect(url_for('/compare/<compare_id>', compare_id=compare_id)) with ConnectTo(CompareDbInterface, self._config) as sc: err = sc.object_existence_quick_check(compare_id) if err is not None: return render_template('compare/error.html', error=err.__str__()) with ConnectTo(InterComFrontEndBinding, self._config) as sc: sc.add_compare_task(compare_id, force=redo) return render_template('compare/wait.html', compare_id=compare_id)
def _calculate_compare_result_id(compare_result): general_keys = list(compare_result['general'].keys()) uids = list(compare_result['general'][general_keys[0]].keys()) comp_id = list_to_unified_string_list(uids) return comp_id