2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-17 15:47:10 +00:00

make more robust against data error

This commit is contained in:
2025-02-19 18:32:58 +02:00
parent a950cc60d9
commit aeaf7cf57f
4 changed files with 18 additions and 11 deletions

View File

@@ -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 ""