mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
[#138] Added a very preliminary version of the prioritization dialog. A big part of this commit is about refactoring the tests and introducing a TestApp for dupeGuru (in core.tests.base).
This commit is contained in:
41
core/prioritize.py
Normal file
41
core/prioritize.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Created By: Virgil Dupras
|
||||
# Created On: 2011/09/07
|
||||
# Copyright 2011 Hardcoded Software (http://www.hardcoded.net)
|
||||
#
|
||||
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
||||
# which should be included with this package. The terms are also available at
|
||||
# http://www.hardcoded.net/licenses/bsd_license
|
||||
|
||||
from hscommon.util import dedupe, flatten
|
||||
|
||||
class CriterionCategory:
|
||||
NAME = "Undefined"
|
||||
|
||||
def __init__(self, results):
|
||||
self.results = results
|
||||
|
||||
#--- Virtual
|
||||
def _extract_value(self, dupe):
|
||||
raise NotImplementedError()
|
||||
|
||||
#--- Public
|
||||
def criteria_list(self):
|
||||
dupes = flatten(g[:] for g in self.results.groups)
|
||||
values = dedupe(self._extract_value(d) for d in dupes)
|
||||
return [Criterion(self, value) for value in values]
|
||||
|
||||
class Criterion:
|
||||
def __init__(self, category, value):
|
||||
self.category = category
|
||||
self.value = value
|
||||
|
||||
@property
|
||||
def display(self):
|
||||
return "{} ({})".format(self.category, self.value)
|
||||
|
||||
|
||||
class KindCategory(CriterionCategory):
|
||||
NAME = "Kind"
|
||||
|
||||
def _extract_value(self, dupe):
|
||||
return dupe.extension
|
||||
Reference in New Issue
Block a user