summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-10-10 15:40:21 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-10-10 15:40:21 +0300
commitff8eaa241e8f23e6c207568c76ce618c358a93eb (patch)
tree32da4120fc320a7096a46b403909f1343d1c62eb
parent52a035e4cf53d16f1b0dc60d7232fb403208ce63 (diff)
downloadtroggle-ff8eaa241e8f23e6c207568c76ce618c358a93eb.tar.gz
troggle-ff8eaa241e8f23e6c207568c76ce618c358a93eb.tar.bz2
troggle-ff8eaa241e8f23e6c207568c76ce618c358a93eb.zip
*team parsing much improved. Copes with everything now.
-rw-r--r--parsers/people.py33
-rw-r--r--parsers/survex.py12
2 files changed, 41 insertions, 4 deletions
diff --git a/parsers/people.py b/parsers/people.py
index 6a4456b..0f3a66e 100644
--- a/parsers/people.py
+++ b/parsers/people.py
@@ -133,15 +133,32 @@ def who_is_this(year,possibleid):
return personexpedition.person
else:
return None
+
+def known_foreigner(id):
+ '''If this someone from ARGE or a known Austrian? Name has to be exact, no soft matching
+ '''
+ friends = ["P. Jeutter", "K. Jäger", "S. Steinberger", "R. Seebacher",
+ "Dominik Jauch", "Fritz Mammel", "Marcus Scheuerman",
+ "Uli Schütz", "Wieland Scheuerle",
+ "Kai Schwekend", "Regina Kaiser", "Thilo Müller","Wieland Scheuerle",
+ "Florian Gruner", "Helmut Stopka-Ebeler", "Aiko", "Mark Morgan"]
+
+ if id in friends:
+ return True
+ else:
+ return False
+
# Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition
-# This is convoluted, the whole personexpedition concept is unnecessary.
+# This is convoluted, the whole personexpedition concept is unnecessary?
Gpersonexpeditionnamelookup = { }
def GetPersonExpeditionNameLookup(expedition):
global Gpersonexpeditionnamelookup
def apply_variations(f, l):
+ '''Be generous in guessing possible matches. Any duplicates will be ruled as invalid.
+ '''
f = f.lower()
l = l.lower()
variations = []
@@ -151,8 +168,9 @@ def GetPersonExpeditionNameLookup(expedition):
variations.append(f + " " + l)
variations.append(f + " " + l[0])
variations.append(f + l[0])
- variations.append(f + l[0] + '.')
+ variations.append(f + " " +l[0] + '.')
variations.append(f[0] + " " + l)
+ variations.append(f[0] + ". " + l)
variations.append(f[0] + l)
variations.append(f[0] + l[0]) # initials e.g. gb or bl
return variations
@@ -188,25 +206,36 @@ def GetPersonExpeditionNameLookup(expedition):
if f == "Robert".lower():
possnames += apply_variations("Bob", l)
+ if f == "Rob".lower():
+ possnames += apply_variations("Robert", l)
+
if f == "Andrew".lower():
possnames += apply_variations("Andy", l)
if f == "Andy".lower():
possnames += apply_variations("Andrew", l)
if f == "Michael".lower():
possnames += apply_variations("Mike", l)
+
if f == "David".lower():
possnames += apply_variations("Dave", l)
if f == "Dave".lower():
possnames += apply_variations("David", l)
+
if f == "Peter".lower():
possnames += apply_variations("Pete", l)
if f == "Pete".lower():
possnames += apply_variations("Peter", l)
+
if f == "Olly".lower():
possnames += apply_variations("Oliver", l)
if f == "Oliver".lower():
possnames += apply_variations("Olly", l)
+ if f == "Ollie".lower():
+ possnames += apply_variations("Oliver", l)
+ if f == "Oliver".lower():
+ possnames += apply_variations("Ollie", l)
+
if f == "Becka".lower():
possnames += apply_variations("Rebecca", l)
diff --git a/parsers/survex.py b/parsers/survex.py
index 714ba67..8d6cb33 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -14,7 +14,7 @@ from django.utils.timezone import make_aware
import troggle.settings as settings
from troggle.core.models.caves import Cave, Entrance, QM, LogbookEntry
from troggle.core.utils import get_process_memory, chaosmonkey
-from troggle.parsers.people import GetPersonExpeditionNameLookup
+from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
from troggle.parsers.logbooks import GetCaveLookup
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.models.survex import SurvexPersonRole, Wallet, SurvexDirectory, SurvexFile, SurvexBlock, SurvexStation
@@ -225,7 +225,7 @@ class LoadingSurvex():
(NB PersonTrip is a logbook thing)
"""
def record_team_member(tm, survexblock):
- tm = tm.strip('\"\'')
+ tm = tm.strip('\"\'').strip()
# Refactor. The dict GetPersonExpeditionNameLookup(expo) indexes by name and has values of personexpedition
# This is convoluted, the whole personexpedition concept is unnecessary.
@@ -251,6 +251,10 @@ class LoadingSurvex():
personrole.expeditionday = survexblock.expeditionday
self.currentpersonexped.append(personexpedition) # used in push/pop block code
personrole.save()
+ elif known_foreigner(tm): # note, not using .lower()
+ message = "- *team {} '{}' known foreigner on *team {} ({}) in '{}'".format(expo.year, tm, survexblock.survexfile.path, survexblock, line)
+ print(self.insp+message)
+ # DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
else:
# we know the date and expo, but can't find the person
message = "! *team {} '{}' FAIL personexpedition lookup on *team {} ({}) in '{}'".format(expo.year, tm, survexblock.survexfile.path, survexblock, line)
@@ -377,6 +381,10 @@ class LoadingSurvex():
pr.person = pr.personexpedition.person
pr.save()
self.currentpersonexped.append(pe) # used in push/pop block code
+ elif known_foreigner(pr.personname): # note, not using .lower()
+ message = "- *team {} '{}' known foreigner on *date {} ({}) in '{}'".format(expo.year, pr.personname, survexblock.survexfile.path, survexblock, line)
+ print(self.insp+message)
+ # DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
else:
message = "! *team {} '{}' FAIL personexpedition lookup on *date {} ({}) '{}'".format(year, pr.personname, survexblock.survexfile.path, survexblock, pr.personname)
print(self.insp+message)