core.results

class dupeguru.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.

forget_moved_ref_marks() → None

Drop the marks of files that are no longer their group’s reference.

Without this, a reference that was marked, lost its position, then got it back, would be marked again without anyone having asked for it.

get_group_of_duplicate(dupe)

Returns Group in which dupe belongs.

is_ref_markable(file: File) → bool

Whether file is a group’s reference that can be marked.

Only with the allow_marking_refs option on, and never for a file from a reference folder (is_ref), whose folder state says it must not be deleted.

is_ref_marked(file: File) → bool

Whether file is a marked reference. A mark is valid only while the file is still its group’s reference.

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

Load results from infile.

Parameters:
  • infile – a file or path pointing to an XML file created with save_to_xml().

  • get_file – a function f(path) returning a File wrapping the path.

  • j – A job progress instance.

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, then on all marked references.

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.

property marked_file_count: int

How many files the actions on marked files act on: marked duplicates and references.

property marked_refs: List[File]

The marked references, in groups order.