mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Add download summary
This commit is contained in:
parent
7024db1f13
commit
f6fbd5e4bb
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,5 +1,8 @@
|
||||
__pycache__/
|
||||
.venv/
|
||||
venv/
|
||||
.idea/
|
||||
build/
|
||||
.mypy_cache/
|
||||
.tmp/
|
||||
.env
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -124,6 +124,7 @@ def main() -> None:
|
||||
cookies="ilias_cookies.txt",
|
||||
)
|
||||
|
||||
pferd.print_summary()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user