2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

abbrv. names now accepted when parsing logbooks, survex

This commit is contained in:
Philip Sargent 2022-10-08 01:52:10 +03:00
parent 55bc042798
commit e9790e70d6
2 changed files with 17 additions and 3 deletions

View File

@ -146,6 +146,8 @@ def GetPersonExpeditionNameLookup(expedition):
#print("Calculating GetPersonExpeditionNameLookup for " + expedition.year)
personexpeditions = PersonExpedition.objects.filter(expedition=expedition)
short = {}
dellist = []
for personexpedition in personexpeditions:
possnames = [ ]
f = unidecode(unescape(personexpedition.person.first_name.lower()))
@ -158,6 +160,12 @@ def GetPersonExpeditionNameLookup(expedition):
possnames.append(f[0] + " " + l)
possnames.append(f[0] + l[0]) # initials e.g. gb or bl
possnames.append(f)
lim = min(4, len(f)+1) # short form, e.g. Dan for Daniel. May be duplicate, e.g. several Dave
if f[:lim] not in short:
short[f[:lim]]= personexpedition
else:
dellist.append(f[:lim])
if full not in possnames:
possnames.append(full)
if personexpedition.nickname not in possnames:
@ -181,6 +189,12 @@ def GetPersonExpeditionNameLookup(expedition):
for possname in duplicates:
del res[possname]
for possname in dellist:
if possname in short: #always true ?
del short[possname]
for shortname in short:
res[shortname] = short[shortname]
Gpersonexpeditionnamelookup[expedition.name] = res
return res

View File

@ -126,7 +126,7 @@ class LoadingSurvex():
rx_teammem = re.compile(r"(?i)"+instruments+"?(?:es|s)?\s+(.*)$")
rx_teamold = re.compile(r"(?i)(.*)\s+"+instruments+"?(?:es|s)?$")
rx_teamabs = re.compile(r"(?i)^\s*("+instruments+")?(?:es|s)?\s*$")
rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$")
rx_person = re.compile(r"(?i) and |/| / |, | & | \+ |^both$|^none$")
rx_qm = re.compile(r'(?i)^\s*QM(\d+)\s+?([a-dA-DxX])\s+([\w\-\_]+)\.([\w\.\-]+)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$')
# does not recognise non numeric suffix survey point ids
rx_qm0 = re.compile(r'(?i)^\s*QM(\d+)\s+(.+)$')
@ -374,11 +374,11 @@ class LoadingSurvex():
# print(self.insp+message)
# DataIssue.objects.create(parser='survex', message=message)
pr.personexpedition = pe
pr.person = p.personexpedition.person
pr.person = pr.personexpedition.person
pr.save()
self.currentpersonexped.append(pe) # used in push/pop block code
else:
message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, p, survexblock.survexfile.path, survexblock, p.personname)
message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, pr, survexblock.survexfile.path, survexblock, pr.personname)
print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))