mirror of
https://github.com/arsenetar/dupeguru.git
synced 2026-01-22 14:41:39 +00:00
[#161 state:fixed] Fixed folder sorting.
This commit is contained in:
@@ -92,10 +92,13 @@ class DupeGuru(RegistrableApplication, Broadcaster):
|
||||
logging.warning("Exception on GetDisplayInfo for %s: %s", str(dupe.path), str(e))
|
||||
return ['---'] * len(self.data.COLUMNS)
|
||||
|
||||
def _create_file(self, path):
|
||||
# We add fs.Folder to fileclasses in case the file we're loading contains folder paths.
|
||||
return fs.get_file(path, self.directories.fileclasses + [fs.Folder])
|
||||
|
||||
def _get_file(self, str_path):
|
||||
path = Path(str_path)
|
||||
# We add fs.Folder to fileclasses in case the file we're loading contains folder paths.
|
||||
f = fs.get_file(path, self.directories.fileclasses + [fs.Folder])
|
||||
f = self._create_file(path)
|
||||
if f is None:
|
||||
return None
|
||||
try:
|
||||
|
||||
@@ -14,9 +14,6 @@ import time
|
||||
|
||||
Column = namedtuple('Column', 'attr display')
|
||||
|
||||
def format_path(p):
|
||||
return str(p[:-1])
|
||||
|
||||
def format_timestamp(t, delta):
|
||||
if delta:
|
||||
return format_time_decimal(t)
|
||||
|
||||
@@ -149,6 +149,10 @@ class File:
|
||||
def name(self):
|
||||
return self.path[-1]
|
||||
|
||||
@property
|
||||
def folder_path(self):
|
||||
return self.path[:-1]
|
||||
|
||||
|
||||
class Folder(File):
|
||||
"""A wrapper around a folder path.
|
||||
|
||||
@@ -328,15 +328,13 @@ class Results(Markable):
|
||||
def sort_dupes(self, key, asc=True, delta=False):
|
||||
if not self.__dupes:
|
||||
self.__get_dupe_list()
|
||||
self.__dupes.sort(key=lambda d: self.data.GetDupeSortKey(d, lambda: self.get_group_of_duplicate(d), key, delta))
|
||||
if not asc:
|
||||
self.__dupes.reverse()
|
||||
keyfunc = lambda d: self.data.GetDupeSortKey(d, lambda: self.get_group_of_duplicate(d), key, delta)
|
||||
self.__dupes.sort(key=keyfunc, reverse=not asc)
|
||||
self.__dupes_sort_descriptor = (key,asc,delta)
|
||||
|
||||
def sort_groups(self,key,asc=True):
|
||||
self.groups.sort(key=lambda g: self.data.GetGroupSortKey(g, key))
|
||||
if not asc:
|
||||
self.groups.reverse()
|
||||
keyfunc = lambda g: self.data.GetGroupSortKey(g, key)
|
||||
self.groups.sort(key=keyfunc, reverse=not asc)
|
||||
self.__groups_sort_descriptor = (key,asc)
|
||||
|
||||
#---Properties
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
# data module for tests
|
||||
|
||||
from hscommon.util import format_size
|
||||
from ..data import format_path, cmp_value, Column
|
||||
from ..data import cmp_value, Column
|
||||
|
||||
COLUMNS = [
|
||||
Column('name', 'Filename'),
|
||||
Column('path', 'Directory'),
|
||||
Column('folder_path', 'Directory'),
|
||||
Column('size', 'Size (KB)'),
|
||||
Column('extension', 'Kind'),
|
||||
]
|
||||
@@ -29,7 +29,7 @@ def GetDisplayInfo(dupe, group, delta):
|
||||
size -= r.size
|
||||
return [
|
||||
dupe.name,
|
||||
format_path(dupe.path),
|
||||
str(dupe.folder_path),
|
||||
format_size(size, 0, 1, False),
|
||||
dupe.extension if hasattr(dupe, 'extension') else '---',
|
||||
]
|
||||
|
||||
@@ -26,6 +26,11 @@ class NamedObject(engine_test.NamedObject):
|
||||
|
||||
def __bool__(self):
|
||||
return False #Make sure that operations are made correctly when the bool value of files is false.
|
||||
|
||||
@property
|
||||
def folder_path(self):
|
||||
return self.path[:-1]
|
||||
|
||||
|
||||
# Returns a group set that looks like that:
|
||||
# "foo bar" (1)
|
||||
|
||||
Reference in New Issue
Block a user