added exit code of 1 when parsing failed and support for more characters in company names

master
Anton Lydike 2 years ago
parent 61c608b44d
commit 8ba46ca3cf

@ -1,6 +1,7 @@
from dataclasses import dataclass from dataclasses import dataclass
import json import json
import re import re
import sys
from typing import Dict, Tuple from typing import Dict, Tuple
from math import ceil, log10 from math import ceil, log10
import datetime import datetime
@ -205,7 +206,7 @@ class MarkdownBlogParser:
def parse(self): def parse(self):
line, span = self.read_until('\n', inclusive=True) 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: if not result:
raise ParseError("Expected review heading of form '### Company \"pesto name\" (variant)\n'", span.transform(end=-1)) raise ParseError("Expected review heading of form '### Company \"pesto name\" (variant)\n'", span.transform(end=-1))
# now we get the first bit of info! # now we get the first bit of info!
@ -329,5 +330,6 @@ if __name__ == '__main__':
}, f, indent=2) }, f, indent=2)
except ParseError as err: except ParseError as err:
err.print_context_message() err.print_context_message()
sys.exit(1)

Loading…
Cancel
Save