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
Groupcontained managed by this instance.
- dupes¶
A list of all duplicates (
Fileinstances), without ref, contained in the currently managedgroups.
- apply_filter(filter_str)¶
Applies a filter
filter_strtogroupsWhen you apply the filter, only dupes with the filename matching
filter_strwill be in in the results. To cancel the filter, just call apply_filter withfilter_strto 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
Groupin whichdupebelongs.
- is_ref_markable(file: File) bool¶
Whether
fileis a group’s reference that can be marked.Only with the
allow_marking_refsoption 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
fileis 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
Filewrapping the path.j – A job progress instance.
- make_ref(dupe)¶
Make
dupetake therefposition of its group.
- perform_on_marked(func, remove_from_results)¶
Performs
funcon all marked dupes, then on all marked references.If an
EnvironmentErroris raised during the call, the problematic dupe is added to self.problems.- Parameters:
remove_from_results (bool) – If true, dupes which had
funcapplied and didn’t cause any problem.
- remove_duplicates(dupes)¶
Remove
dupesfrom their respectiveGroup.Also, remove the group from
groupsif it ends up empty.
- save_to_xml(outfile)¶
Save results to
outfilein XML.- Parameters:
outfile – file object or path.
- sort_dupes(key, asc=True, delta=False)¶
Sort
dupesaccording tokey.- 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
groupsaccording tokey.The
refof 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.