From f68849c65f37d7fa3949466bdd67039ed67a07ae Mon Sep 17 00:00:00 2001 From: Joscha Date: Tue, 25 May 2021 15:42:46 +0200 Subject: [PATCH] Fix rules not being parsed entirely --- PFERD/__main__.py | 16 ++++++---------- PFERD/pferd.py | 4 +++- PFERD/transformer.py | 7 +++++++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/PFERD/__main__.py b/PFERD/__main__.py index 5fd9447..b7c5fa9 100644 --- a/PFERD/__main__.py +++ b/PFERD/__main__.py @@ -112,32 +112,28 @@ def main() -> None: log.error(str(e)) exit(1) - error = False try: asyncio.run(pferd.run()) except ConfigOptionError as e: log.unlock() log.error(str(e)) - error = True + exit(1) except RuleParseError as e: log.unlock() e.pretty_print() - error = True + exit(1) except KeyboardInterrupt: log.unlock() log.explain_topic("Interrupted, exiting immediately") log.explain("Open files and connections are left for the OS to clean up") log.explain("Temporary files are not cleaned up") + pferd.print_report() # TODO Clean up tmp files # And when those files *do* actually get cleaned up properly, - # reconsider if this should be an error - error = True + # reconsider if this should really exit with 1 + exit(1) except Exception: log.unlock() log.unexpected_exception() - error = True - - pferd.print_report() - - if error: + pferd.print_report() exit(1) diff --git a/PFERD/pferd.py b/PFERD/pferd.py index c0b48a7..434407d 100644 --- a/PFERD/pferd.py +++ b/PFERD/pferd.py @@ -119,7 +119,9 @@ class Pferd: def print_report(self) -> None: for name in self._crawlers_to_run: - crawler = self._crawlers[name] + crawler = self._crawlers.get(name) + if crawler is None: + continue # Crawler failed to load log.report("") log.report(f"[bold bright_cyan]Report[/] for {escape(name)}") diff --git a/PFERD/transformer.py b/PFERD/transformer.py index 5a20207..0f2a3e6 100644 --- a/PFERD/transformer.py +++ b/PFERD/transformer.py @@ -266,6 +266,11 @@ def parse_whitespace(line: Line) -> None: line.advance() +def parse_eol(line: Line) -> None: + if line.get() is not None: + raise RuleParseError(line, "Expected end of line") + + def parse_rule(line: Line) -> Rule: # Parse left side leftindex = line.index @@ -291,6 +296,8 @@ def parse_rule(line: Line) -> Rule: else: rightpath = PurePath(right) + parse_eol(line) + # Dispatch if arrowname == "": return NormalRule(PurePath(left), rightpath)