diff --git a/parsers/survex.py b/parsers/survex.py index c08faee..75db0c6 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -96,6 +96,13 @@ class SurvexLeg(): compass = 0.0 clino = 0.0 +def get_people_on_trip(survexblock): + qpeople = SurvexPersonRole.objects.filter(survexblock=survexblock) + people = [] + for p in qpeople: + people.append(f'{p.personname}') + return list(set(people)) + class LoadingSurvex(): """A 'survex block' is a *begin...*end set of cave data. A survex file can contain many begin-end blocks, which can be nested, and which can *include @@ -140,7 +147,8 @@ class LoadingSurvex(): rx_argsref = re.compile(r'(?i)^[\s.:]*((?:19[6789]\d)|(?:20[012345]\d))\s*#?\s*(X)?\s*(.*?\d+.*?)$') rx_badmerge= re.compile(r'(?i).*(\>\>\>\>\>)|(\=\=\=\=\=)|(\<\<\<\<\<).*$') rx_ref2 = re.compile(r'(?i)\s*ref[.;]?') - + rx_commteam = re.compile(r'(?i)\s*(Messteam|Zeichner)\s*[:]?(.*)') + # This interprets the survex "*data normal" command which sets out the order of the fields in the data, e.g. # *DATA normal from to length gradient bearing ignore ignore ignore ignore @@ -311,14 +319,16 @@ class LoadingSurvex(): setdate(year) elif len(line) == 7: year = line[:4] - message = "! DATE Warning only accurate to the month, setting to 1st '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path) + perps = get_people_on_trip(survexblock) # What, you don't know Judge Dredd slang ? + message = f"! DATE Warning only accurate to the month, setting to 1st '{oline}' ({survexblock}) {survexblock.survexfile.path} {perps}" print(self.insp+message) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path)) survexblock.date = datetime.strptime(line.replace('.','-'), '%Y-%m') # sets to first of month setdate(year) elif len(line) == 4: year = line[:4] - message = "! DATE WARNING only accurate to the YEAR, setting to 1st January '{}' ({}) {}".format(oline, survexblock, survexblock.survexfile.path) + perps = get_people_on_trip(survexblock) + message = f"! DATE WARNING only accurate to the YEAR, setting to 1st January '{oline}' ({survexblock}) {survexblock.survexfile.path} {perps}" print(self.insp+message) DataIssue.objects.create(parser='survex', message=message, url=get_offending_filename(survexblock.survexfile.path)) survexblock.date = datetime.strptime(line, '%Y') # sets to January 1st @@ -472,7 +482,8 @@ class LoadingSurvex(): # delete the object to save memory survexleg = None - + + def LoadSurvexRef(self, survexblock, args): #print(self.insp+ "*REF ---- '"+ args +"'") url= get_offending_filename(survexblock.survexfile.path) @@ -493,7 +504,8 @@ class LoadingSurvex(): if argsgps: yr, letterx, wallet = argsgps.groups() else: - message = " ! Wallet *REF '{}' malformed id in '{}' ".format(args, survexblock.survexfile.path) + perps = get_people_on_trip(survexblock) + message = f" ! Wallet *REF '{args}' malformed id in '{survexblock.survexfile.path}' {perps}" print(self.insp+message) DataIssue.objects.create(parser='survex', message=message, url=url) return @@ -530,7 +542,8 @@ class LoadingSurvex(): print(self.insp+message) DataIssue.objects.create(parser='survex', message=message, url=url) else: - message = " ! Wallet *REF '{}' - NOT found '{}' in database".format(refscan, survexblock.survexfile.path) + perps = get_people_on_trip(survexblock) + message = f" ! Wallet *REF '{refscan}' in '{survexblock.survexfile.path}' {perps} NOT in database i.e. wallet does not exist." print(self.insp+message) DataIssue.objects.create(parser='survex', message=message, url=url) @@ -854,7 +867,7 @@ class LoadingSurvex(): def LoadSurvexComment(self, survexblock, comment): # ignore all comments except ;ref, ; wallet and ;QM and ;*include (for collated survex file) # rx_ref2 = re.compile(r'(?i)\s*ref[.;]?') - + # This should also check that the QM survey point rxists in the block refline = self.rx_commref.match(comment) @@ -863,6 +876,16 @@ class LoadingSurvex(): comment = self.rx_ref2.sub("",comment.strip()) print(f'rx_ref2 -- {comment=} in {survexblock.survexfile.path} :: {survexblock}') self.LoadSurvexRef(survexblock, comment) + + # handle + # ; Messteam: Jörg Haussmann, Robert Eckardt, Thilo Müller + # ; Zeichner: Thilo Müller + # But none of these will be valid teammembers because they are not actually on our expo + + team = self.rx_commteam.match(comment) + if team: + print(f'rx_commteam -- {comment=} in {survexblock.survexfile.path} :: {survexblock}') + pass qml = self.rx_qm0.match(comment) if qml: