Looks like sorting of DifferenceEntry's works (?)
This commit is contained in:
parent
856d8a99b9
commit
a4877e1455
@ -15,6 +15,7 @@ Released under the GNU GENERAL PUBLIC LICENSE v3 (See LICENSE file for more)
|
|||||||
|
|
||||||
#
|
#
|
||||||
import datetime
|
import datetime
|
||||||
|
import functools
|
||||||
import humanfriendly
|
import humanfriendly
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -80,6 +81,7 @@ class BackupDiff:
|
|||||||
|
|
||||||
elif arg == "--no-clean":
|
elif arg == "--no-clean":
|
||||||
self.__do_clean_difference_entries = False
|
self.__do_clean_difference_entries = False
|
||||||
|
self.log("Won't clean Difference entries")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def consume_argument_companion(arg_index):
|
def consume_argument_companion(arg_index):
|
||||||
@ -331,6 +333,32 @@ class BackupDiff:
|
|||||||
|
|
||||||
return entry
|
return entry
|
||||||
|
|
||||||
|
def sort_difference_entries(self, entries):
|
||||||
|
|
||||||
|
entries.sort(
|
||||||
|
key=functools.cmp_to_key(
|
||||||
|
lambda entry_a, entry_b: BackupDiff.sort_difference_entries_key_callback(entry_a, entry_b)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def sort_difference_entries_key_callback(entry_a, entry_b):
|
||||||
|
|
||||||
|
if entry_a.get_is_dir() and not entry_b.get_is_dir():
|
||||||
|
return -1
|
||||||
|
if not entry_a.get_is_dir() and entry_b.get_is_dir():
|
||||||
|
return 1
|
||||||
|
|
||||||
|
item_a = entry_a.get_item()
|
||||||
|
item_b = entry_b.get_item()
|
||||||
|
|
||||||
|
if item_a > item_b:
|
||||||
|
return -1
|
||||||
|
elif item_b > item_b:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
def generate_report(self):
|
def generate_report(self):
|
||||||
|
|
||||||
# Start report structure
|
# Start report structure
|
||||||
@ -391,6 +419,10 @@ class BackupDiff:
|
|||||||
if entry.get_is_different_sizes():
|
if entry.get_is_different_sizes():
|
||||||
report["size_difference"]["entries"].append(entry)
|
report["size_difference"]["entries"].append(entry)
|
||||||
|
|
||||||
|
# Sort all entries
|
||||||
|
for section_key in report:
|
||||||
|
self.sort_difference_entries(report[section_key]["entries"])
|
||||||
|
|
||||||
return report
|
return report
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user