summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2022-07-08 20:08:42 +0300
committerPhilip Sargent <philip.sargent@klebos.com>2022-07-08 20:08:42 +0300
commitca5586fc4233a93ba93ee8d4a87ff63f3a0483c3 (patch)
treedaa5f54691bf078a1562ba1e599946d860ac27e1
parentd3572e18c34c20c661eb61c7f8c46358f7223d37 (diff)
downloadtroggle-ca5586fc4233a93ba93ee8d4a87ff63f3a0483c3.tar.gz
troggle-ca5586fc4233a93ba93ee8d4a87ff63f3a0483c3.tar.bz2
troggle-ca5586fc4233a93ba93ee8d4a87ff63f3a0483c3.zip
Report badly formatted ;QM lines
-rw-r--r--parsers/survex.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index e4ec8b3..acc76dd 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -118,6 +118,7 @@ class LoadingSurvex():
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_qm0 = re.compile(r'(?i)^\s*QM(\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).*$')
@@ -508,6 +509,7 @@ class LoadingSurvex():
def LoadSurvexQM(self, survexblock, qmline):
insp = self.insp
+
qm_no = qmline.group(1) # this may not be unique across multiple survex files
qm_grade = qmline.group(2)
@@ -820,9 +822,16 @@ class LoadingSurvex():
if implicitline:
self.LoadSurvexRef(survexblock, comment)
- qmline = self.rx_qm.match(comment)
- if qmline:
- self.LoadSurvexQM(survexblock, qmline)
+ qml = self.rx_qm0.match(comment)
+ if qml:
+ qmline = self.rx_qm.match(comment)
+ if qmline:
+ self.LoadSurvexQM(survexblock, qmline)
+ else:
+ message = f' ! QM Unrecognised as a valid QM in "{survexblock.survexfile.path}" {qml}'
+ print(message)
+ DataIssue.objects.create(parser='survex', message=message)
+
included = self.rx_comminc.match(comment)
# ;*include means 'we have been included'; whereas *include means 'proceed to include'