core.results

class core.results.Results(app)

Manages a collection of duplicate Group.

This class takes care or marking, sorting and filtering duplicate groups.

groups

The list of Group contained managed by this instance.

dupes

A list of all duplicates (File instances), without ref, contained in the currently managed groups.

apply_filter(filter_str)

Applies a filter filter_str to groups

When you apply the filter, only dupes with the filename matching filter_str will be in in the results. To cancel the filter, just call apply_filter with filter_str to None, and the results will go back to normal.

If call apply_filter on a filtered results, the filter will be applied on the filtered results.

Parameters:filter_str (str) – a string containing a regexp to filter dupes with.
get_group_of_duplicate(dupe)

Returns Group in which dupe belongs.

load_from_xml(infile, get_file, j=<hscommon.jobprogress.job.NullJob object>)

Load results from infile.

Parameters:
make_ref(dupe)

Make dupe take the ref position of its group.

perform_on_marked(func, remove_from_results)

Performs func on all marked dupes.

If an EnvironmentError is raised during the call, the problematic dupe is added to self.problems.

Parameters:remove_from_results (bool) – If true, dupes which had func applied and didn’t cause any problem.
remove_duplicates(dupes)

Remove dupes from their respective Group.

Also, remove the group from groups if it ends up empty.

save_to_xml(outfile)

Save results to outfile in XML.

Parameters:outfile – file object or path.
sort_dupes(key, asc=True, delta=False)

Sort dupes according to key.

Parameters:
  • key (str) – key attribute name to sort with.
  • asc (bool) – If false, sorting is reversed.
  • delta (bool) – If true, sorting occurs using delta values.
sort_groups(key, asc=True)

Sort groups according to key.

The ref of each group is used to extract values for sorting.

Parameters:
  • key (str) – key attribute name to sort with.
  • asc (bool) – If false, sorting is reversed.