From 8ebf0eab169a72eb0f82e410a2391886e3a6aeb1 Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Tue, 17 Nov 2020 21:36:04 +0100 Subject: [PATCH] Sort download summary --- PFERD/download_summary.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PFERD/download_summary.py b/PFERD/download_summary.py index c8135de..3b9a024 100644 --- a/PFERD/download_summary.py +++ b/PFERD/download_summary.py @@ -5,6 +5,12 @@ from pathlib import Path from typing import List +def _mergeNoDuplicate(first: List[Path], second: List[Path]) -> List[Path]: + tmp = list(set(first + second)) + tmp.sort(key=lambda x: str(x.resolve())) + return tmp + + class DownloadSummary: """ Keeps track of all new, modified or deleted files and provides a summary. @@ -40,9 +46,9 @@ class DownloadSummary: """ Merges ourselves with the passed summary. Modifies this object, but not the passed one. """ - self._new_files = list(set(self._new_files + summary.new_files)) - self._modified_files = list(set(self._modified_files + summary.modified_files)) - self._deleted_files = list(set(self._deleted_files + summary.deleted_files)) + self._new_files = _mergeNoDuplicate(self._new_files, summary.new_files) + self._modified_files = _mergeNoDuplicate(self._modified_files, summary.modified_files) + self._deleted_files = _mergeNoDuplicate(self._deleted_files, summary.deleted_files) def add_deleted_file(self, path: Path) -> None: """