diff options
Diffstat (limited to 'parsers/people.py')
-rw-r--r-- | parsers/people.py | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/parsers/people.py b/parsers/people.py index cc061ef..12fba14 100644 --- a/parsers/people.py +++ b/parsers/people.py @@ -112,7 +112,7 @@ def load_people_expos(): vfho = True lookupAttribs={'first_name':firstname, 'last_name':(lastname or "")} - nonLookupAttribs={'is_vfho':vfho, 'fullname':fullname} + nonLookupAttribs={'is_vfho':vfho, 'fullname':fullname, 'nickname':nickname} person, created = save_carefully(Person, lookupAttribs, nonLookupAttribs) parse_blurb(personline=personline, header=header, person=person) @@ -131,6 +131,14 @@ def load_people_expos(): # expedition name lookup cached for speed (it's a very big list) # should have a LIST of nicknames, just populate the first entry from folk.csv +def who_is_this(year,possibleid): + expo = Expedition.objects.filter(year=year) + personexpedition = GetPersonExpeditionNameLookup(expo)[possibleid.lower()] + if personexpedition: + return personexpedition.person + else: + return None + # Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition # This is convoluted, the whole personexpedition concept is unnecessary. @@ -161,6 +169,19 @@ def GetPersonExpeditionNameLookup(expedition): possnames.append(f[0] + l[0]) # initials e.g. gb or bl possnames.append(f) + # But these aliases do not take advantage of the variations above + if f'{f} {l}' == "Phil Underwood": + possnames.append("Phil Underpants") + if f'{f} {l}' == "Naomi Griffiths": + possnames.append("Naomi Makin") + if f'{f} {l}' == "Cat Hulse": + possnames.append("Catherine Hulse") + possnames.append("Cat Henry") + if f'{f} {l}' == "Jess Stirrups": + possnames.append("Jessica Stirrups") + if f'{f} {l}' == "Nat Dalton": + possnames.append("Nathaniel Dalton") + 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 @@ -173,12 +194,13 @@ def GetPersonExpeditionNameLookup(expedition): if l: # This allows for nickname to be used for short name # eg Phil S is adding Phil Sargent to the list - if str(personexpedition.nickname.lower() + " " + l) not in possnames: - possnames.append(personexpedition.nickname.lower() + " " + l) - if str(personexpedition.nickname.lower() + " " + l[0]) not in possnames: - possnames.append(personexpedition.nickname.lower() + " " + l[0]) - if str(personexpedition.nickname.lower() + l[0]) not in possnames: - possnames.append(personexpedition.nickname.lower() + l[0]) + n = personexpedition.nickname.lower() + if str(n + " " + l) not in possnames: + possnames.append(n + " " + l) + if str(n + " " + l[0]) not in possnames: + possnames.append(n + " " + l[0]) + if str(n + l[0]) not in possnames: + possnames.append(n + l[0]) for possname in possnames: if possname in res: @@ -195,6 +217,10 @@ def GetPersonExpeditionNameLookup(expedition): for shortname in short: res[shortname] = short[shortname] + print(f'{expedition.name}', end= ' ') + for n in res: + print(f'{n},', end= ' ') + print('') Gpersonexpeditionnamelookup[expedition.name] = res return res |