From aeaf7cf57f2360ef4a6d459d5e84901f301cfb8b Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 19 Feb 2025 18:32:58 +0200 Subject: make more robust against data error --- parsers/people.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'parsers/people.py') diff --git a/parsers/people.py b/parsers/people.py index b6b8159..0a05efb 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -137,10 +137,15 @@ def load_people_expos(): nick = "" rawlastname = personline[header["Lastname"]].strip() - matchlastname = re.match(r"^([\w&;\s]+)(?:\(([^)]*)\))?", rawlastname) - lastname = matchlastname.group(1).strip() + if rawlastname == "": + print(f"MISSING SURNAME FIELD for {name} - check against similar names in the list to see what you have done.") + if matchlastname := re.match(r"^([\w&;\s]+)(?:\(([^)]*)\))?", rawlastname): + lastname = matchlastname.group(1).strip() + else: + print(f"MATCH FAIL {personline=}\n {slug=}\n {name=}\n {rawlastname=}") + exit(1) - splitnick = re.match(r"^([\w&;\s]+)(?:\(([^)]*)\))?", plainname) + splitnick = re.match(r"^([\w&;\s\-]+)(?:\(([^)]*)\))?", plainname) fullname = splitnick.group(1) # removes Nickname in brackets, but also cuts hyphenated names nick = splitnick.group(2) or "" -- cgit v1.2.3