From e0b46a306ae605841521121ef0c3b083fdb34ba8 Mon Sep 17 00:00:00 2001 From: I-Al-Istannen Date: Sat, 25 Apr 2020 20:05:19 +0200 Subject: [PATCH] Use warn method in IliasCrawler --- PFERD/ilias/crawler.py | 8 +++++--- PFERD/logging.py | 6 ++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/PFERD/ilias/crawler.py b/PFERD/ilias/crawler.py index e3e27cb..6901c1c 100644 --- a/PFERD/ilias/crawler.py +++ b/PFERD/ilias/crawler.py @@ -111,9 +111,11 @@ class IliasCrawler: LOGGER.debug("Processing folder-like...") return self._switch_on_folder_like(path, link_element, url) - LOGGER.warning("Got unknown type, %r, %r, %r", path, link_element, url) - # TODO: Other types - raise Exception("Implement me!") + PRETTY.warn( + "Got unknown element type in switch. I am not sure what horror I found on the" + f" ILIAS page. The element was at {str(path)!r} and it is {link_element!r})" + ) + return [] @staticmethod def _crawl_file(path: Path, link_element: bs4.Tag, url: str) -> List[IliasDownloadInfo]: diff --git a/PFERD/logging.py b/PFERD/logging.py index 65f8f81..567a69e 100644 --- a/PFERD/logging.py +++ b/PFERD/logging.py @@ -40,6 +40,12 @@ def enable_logging(name: str = "PFERD", level: int = logging.INFO) -> None: colorama.init() +class FatalException(Exception): + """ + A fatal exception occurred. Recovery is not possible. + """ + + class PrettyLogger: """ A logger that prints some specially formatted log messages in color.