diff --git a/.gitignore b/.gitignore index 8e46ec0..0d18aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ __pycache__/ .venv/ +venv/ +.idea/ +build/ .mypy_cache/ .tmp/ .env diff --git a/PFERD/organizer.py b/PFERD/organizer.py index d6f9790..ab32321 100644 --- a/PFERD/organizer.py +++ b/PFERD/organizer.py @@ -24,6 +24,9 @@ class FileAcceptException(Exception): class Organizer(Location): """A helper for managing downloaded files.""" + new_files = [] + modified_files = [] + def __init__(self, path: Path): """Create a new organizer for a given path.""" super().__init__(path) @@ -69,8 +72,10 @@ class Organizer(Location): dst_absolute.touch() return + self.modified_files.append(dst_absolute) PRETTY.modified_file(dst_absolute) else: + self.new_files.append(dst_absolute) PRETTY.new_file(dst_absolute) # Create parent dir if needed diff --git a/PFERD/pferd.py b/PFERD/pferd.py index 92cdd78..4f8eedb 100644 --- a/PFERD/pferd.py +++ b/PFERD/pferd.py @@ -34,6 +34,9 @@ class Pferd(Location): useful shortcuts for running synchronizers in a single interface. """ + new_files = [] + modified_files = [] + def __init__( self, base_dir: Path, @@ -139,7 +142,8 @@ class Pferd(Location): # This authenticator only works with the KIT ilias instance. authenticator = KitShibbolethAuthenticator(username=username, password=password) PRETTY.starting_synchronizer(target, "ILIAS", course_id) - return self._ilias( + + organizer = self._ilias( target=target, base_url="https://ilias.studium.kit.edu/", crawl_function=lambda crawler: crawler.crawl_course(course_id), @@ -151,6 +155,31 @@ class Pferd(Location): clean=clean, ) + self.new_files += organizer.new_files + self.modified_files += organizer.modified_files + + return organizer + + def print_summary(self): + LOGGER.info("") + LOGGER.info("Summary: ") + if len(self.new_files) == 0 and len(self.modified_files) == 0: + LOGGER.info("Nothing changed") + + if len(self.new_files) > 0: + LOGGER.info("New Files:") + for file in self.new_files: + PRETTY.new_file(file) + + LOGGER.info("") + + if len(self.modified_files) > 0: + LOGGER.info("Modified Files:") + for file in self.modified_files: + PRETTY.modified_file(file) + + LOGGER.info("") + @swallow_and_print_errors def ilias_kit_personal_desktop( self, diff --git a/example_config.py b/example_config.py index 0dcad4a..9072b2e 100644 --- a/example_config.py +++ b/example_config.py @@ -124,6 +124,7 @@ def main() -> None: cookies="ilias_cookies.txt", ) + pferd.print_summary() if __name__ == "__main__": main()