summaryrefslogtreecommitdiffstats
path: root/parsers/survex.py
diff options
context:
space:
mode:
Diffstat (limited to 'parsers/survex.py')
-rw-r--r--parsers/survex.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 876263c..0656c57 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -119,9 +119,10 @@ class LoadingSurvex():
instruments = "(waiting_patiently|slacker|Useless|nagging|unknown|Inst|instrument|rig|rigger|rigging|helper|something| compass|comp|clino|Notes|sketch|book|Tape|Dog|Pics|photo|drawing|Helper|GPS|Disto|Distox|Distox2|topodroid|point|Consultant|nail|polish|nail_polish_bitch|nail_polish_monkey|varnish|nail_polish|nail_varnish|bitch|monkey|PowerDrill|drill)"
rx_teammem = re.compile(r"(?i)"+instruments+"?(?:es|s)?\s+(.*)"+instruments+"?(?:es|s)?$")
rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$")
- rx_qm = re.compile(r'(?i)^\s*QM(\d+)\s+?([a-dA-DxX])\s+([\w\-]+)\.(\d+)\s+(([\w\-]+)\.(\d+)|\-)\s+(.+)$')
+ 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+(.+)$')
+ rx_qm_tick = re.compile(r'(?i)^\s*QM(\d+)\s+TICK\s([\d\-]+)\s(.*)$')
# remember there is also QM_PATTERN used in views.other and set in settings.py
rx_tapelng = re.compile(r'(?i).*(tape|length).*$')
@@ -510,6 +511,23 @@ class LoadingSurvex():
print((self.insp+message))
DataIssue.objects.create(parser='survex', message=message, url=url)
+ def TickSurvexQM(self, survexblock, qmtick):
+ # Now we need to find the correct QM object. It will be in the same block and have the same number.
+
+ try:
+ qm = QM.objects.filter(block=survexblock, number=int(qmtick.group(1)))
+ except:
+ #raise
+ message = f' ! QM TICK find FAIL QM{qmtick.group(1)} date:"{qmtick.group(2)}" qmlist:"{qm}" in "{survexblock.survexfile.path}" + comment:"{qmtick.group(3)}" '
+ print(message)
+ DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx')
+ if len(qm)>1:
+ message = f' ! QM TICK MULTIPLE found FAIL QM{qmtick.group(1)} date:"{qmtick.group(2)}" in "{survexblock.survexfile.path}" + comment:"{qmtick.group(3)}" '
+ print(message)
+ DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx')
+ qm[0].ticked = True
+ qm[0].save()
+
def LoadSurvexQM(self, survexblock, qmline):
insp = self.insp
@@ -821,9 +839,13 @@ class LoadingSurvex():
if qmline:
self.LoadSurvexQM(survexblock, qmline)
else:
- message = f' ! QM Unrecognised as valid in "{survexblock.survexfile.path}" QM{qml.group(1)} {qml.group(2)} : non-numeric station name?'
- print(message)
- DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx')
+ qmtick = self.rx_qm_tick.match(comment)
+ if qmtick:
+ self.TickSurvexQM(survexblock, qmtick)
+ else:
+ message = f' ! QM Unrecognised as valid in "{survexblock.survexfile.path}" QM{qml.group(1)} "{qml.group(2)}" : regex failure, typo?'
+ print(message)
+ DataIssue.objects.create(parser='survex', message=message, url=f'/survexfile/{survexblock.survexfile.path}.svx')
included = self.rx_comminc.match(comment)
@@ -1456,6 +1478,7 @@ def LoadSurvexBlocks():
SurvexDirectory.objects.all().delete()
SurvexPersonRole.objects.all().delete()
SurvexStation.objects.all().delete()
+ QM.objects.all().delete() # most of these are created by survex parsing. Better to lose the CSV ones than duplicate the survex ones
print(" - survex Data Issues flushed")
DataIssue.objects.filter(parser='survex').delete()
DataIssue.objects.filter(parser='survexleg').delete()