Fix rules not being parsed entirely

This commit is contained in:
Joscha 2021-05-25 15:42:46 +02:00
parent edb52a989e
commit f68849c65f
3 changed files with 16 additions and 11 deletions

View File

@ -112,32 +112,28 @@ def main() -> None:
log.error(str(e)) log.error(str(e))
exit(1) exit(1)
error = False
try: try:
asyncio.run(pferd.run()) asyncio.run(pferd.run())
except ConfigOptionError as e: except ConfigOptionError as e:
log.unlock() log.unlock()
log.error(str(e)) log.error(str(e))
error = True exit(1)
except RuleParseError as e: except RuleParseError as e:
log.unlock() log.unlock()
e.pretty_print() e.pretty_print()
error = True exit(1)
except KeyboardInterrupt: except KeyboardInterrupt:
log.unlock() log.unlock()
log.explain_topic("Interrupted, exiting immediately") log.explain_topic("Interrupted, exiting immediately")
log.explain("Open files and connections are left for the OS to clean up") log.explain("Open files and connections are left for the OS to clean up")
log.explain("Temporary files are not cleaned up") log.explain("Temporary files are not cleaned up")
pferd.print_report()
# TODO Clean up tmp files # TODO Clean up tmp files
# And when those files *do* actually get cleaned up properly, # And when those files *do* actually get cleaned up properly,
# reconsider if this should be an error # reconsider if this should really exit with 1
error = True exit(1)
except Exception: except Exception:
log.unlock() log.unlock()
log.unexpected_exception() log.unexpected_exception()
error = True pferd.print_report()
pferd.print_report()
if error:
exit(1) exit(1)

View File

@ -119,7 +119,9 @@ class Pferd:
def print_report(self) -> None: def print_report(self) -> None:
for name in self._crawlers_to_run: 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("")
log.report(f"[bold bright_cyan]Report[/] for {escape(name)}") log.report(f"[bold bright_cyan]Report[/] for {escape(name)}")

View File

@ -266,6 +266,11 @@ def parse_whitespace(line: Line) -> None:
line.advance() 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: def parse_rule(line: Line) -> Rule:
# Parse left side # Parse left side
leftindex = line.index leftindex = line.index
@ -291,6 +296,8 @@ def parse_rule(line: Line) -> Rule:
else: else:
rightpath = PurePath(right) rightpath = PurePath(right)
parse_eol(line)
# Dispatch # Dispatch
if arrowname == "": if arrowname == "":
return NormalRule(PurePath(left), rightpath) return NormalRule(PurePath(left), rightpath)