summaryrefslogtreecommitdiffstats
path: root/parsers/survex.py
diff options
context:
space:
mode:
Diffstat (limited to 'parsers/survex.py')
-rw-r--r--parsers/survex.py52
1 files changed, 27 insertions, 25 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 57ae52c..1782994 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -234,34 +234,36 @@ class LoadingSurvex():
# we will have to attach them to the survexblock anyway, and then do a
# later check on whether they are valid when we get the date.
- personrole, created = SurvexPersonRole.objects.update_or_create(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
expo = survexblock.expedition # may be None if no *date yet
# this syntax was bizarre.. made more obvious
if expo:
- if survexblock.expeditionday: # *date has been set
- personrole.expeditionday = survexblock.expeditionday
- else:
+ if not survexblock.expeditionday: # *date has been set
# should not happen
- message = "! *team {} expo ok, expedition day not in *team {} ({}) created? '{}'".format(expo.year, survexblock.survexfile.path, survexblock, created )
+ message = "! *team {} expo ok, expedition day not in *team {} ({}) ".format(expo.year, survexblock.survexfile.path, survexblock )
print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
-
-
+
personexpedition = GetPersonExpeditionNameLookup(expo).get(tm.lower())
- personrole.person=personexpedition.person
- self.currentpersonexped.append(personexpedition)
-
- if not personexpedition:
+ if personexpedition:
+ personrole, created = SurvexPersonRole.objects.update_or_create(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
+ personrole.person=personexpedition.person
+ personrole.expeditionday = survexblock.expeditionday
+ self.currentpersonexped.append(personexpedition) # used in push/pop block code
+ personrole.save()
+ 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, created, line)
+ message = "! *team {} '{}' FAIL personexpedition lookup 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:
personexpedition = None
- # don't know the date yet, assume the person is valid. It wull get picked up with the *date appears
+ personrole, created = SurvexPersonRole.objects.update_or_create(survexblock=survexblock, personexpedition=personexpedition, personname=tm)
+ # don't know the date yet, so cannot query the table about validity.
+ # assume the person is valid. It will get picked up with the *date appears
+ personrole.save()
- personrole.save()
+
mteammember = self.rx_teammem.match(line) # matches the role at the beginning
if not mteammember:
@@ -352,34 +354,34 @@ class LoadingSurvex():
# we should make this a date RANGE for everything?
def setdate_on_survexblock(year):
+ # We are assuming that deferred *team people are in the same block. Otherwise, ouch.
expo = self.get_expo_from_year(year)
survexblock.expedition = expo
survexblock.expeditionday = expo.get_expedition_day(survexblock.date)
survexblock.save()
team = SurvexPersonRole.objects.filter(survexblock=survexblock)
- for p in team:
- if not p.expeditionday: # *date and *team in 'wrong' order. All working now.
+ for pr in team:
+ if not pr.expeditionday: # *date and *team in 'wrong' order. All working now.
- p.expeditionday = survexblock.expeditionday
- p.save()
+ pr.expeditionday = survexblock.expeditionday
+ pr.save()
- if not p.personexpedition: # again, we didn't know the date until now
- pe = GetPersonExpeditionNameLookup(expo).get(p.personname.lower())
+ if not pr.personexpedition: # again, we didn't know the date until now
+ pe = GetPersonExpeditionNameLookup(expo).get(pr.personname.lower())
if pe:
# message = "! {} ({}) Fixing undated personexpedition '{}'".format(survexblock.survexfile.path, survexblock, p.personname)
# print(self.insp+message)
# DataIssue.objects.create(parser='survex', message=message)
- p.personexpedition = pe
- p.person = p.personexpedition.person
- p.save()
+ pr.personexpedition = pe
+ pr.person = p.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)
print(self.insp+message)
DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path))
-
-
oline = line
if len(line) > 10:
# message = "! DATE Warning LONG DATE '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path)