From 8ba46ca3cf667dab8023026e21a94081b666b305 Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Tue, 9 Aug 2022 12:53:06 +0200 Subject: [PATCH] added exit code of 1 when parsing failed and support for more characters in company names --- parse-md.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/parse-md.py b/parse-md.py index 280ab77..9afb8e1 100644 --- a/parse-md.py +++ b/parse-md.py @@ -1,6 +1,7 @@ from dataclasses import dataclass import json import re +import sys from typing import Dict, Tuple from math import ceil, log10 import datetime @@ -205,7 +206,7 @@ class MarkdownBlogParser: def parse(self): line, span = self.read_until('\n', inclusive=True) - result = re.fullmatch(r'### ([\w\s]+)\s+("[^"]+")[ \t]*(\([^)]+\))?\n', line) + result = re.fullmatch(r'### ([\w\s&-/]+)\s+("[^"]+")[ \t]*(\([^)]+\))?\n', line) if not result: raise ParseError("Expected review heading of form '### Company \"pesto name\" (variant)\n'", span.transform(end=-1)) # now we get the first bit of info! @@ -329,5 +330,6 @@ if __name__ == '__main__': }, f, indent=2) except ParseError as err: err.print_context_message() + sys.exit(1)