2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-02-08 06:08:21 +00:00

tighten QM recognizer to prevent spurious warnings

This commit is contained in:
2025-08-27 16:59:38 +01:00
parent afe9190c97
commit 8e147986ae

View File

@@ -303,16 +303,16 @@ class LoadingSurvex:
rx_quotedtitle = re.compile(r'(?i)^"(.*)"$')
# QM recognizers
rx_qm0 = re.compile(r"(?i)^\s*QM(\d+)\s+(.+)$") # correct
rx_qm1 = re.compile(r"(?i)^\s*QM(\w+)\s+(.+)$") # to detect errors
rx_qm_digit = re.compile(r"(?i)^\s*QM(\d+)\s+(.+)$") # correct
rx_qm_detect = re.compile(r"(?i)^\s*QM\s+(\d+).*")
# remember there is also QM_PATTERN used in views.other and set in settings.py
rx_qm = re.compile(
r"^\s*QM(\d+)\s+([A-DVXa-dvx?])\s+([\w\-_]+\.[\w.\-]+)\s*(\-|[\w\-]+\.[\w.\-]+)(\s+.*)?$"
r"^\s*QM(\d+)\s+([A-DVXa-dvx?])\s+([\w\-_]+\.[\w.\-]+)\s+(\-|[\w\-]+\.[\w.\-]+)(\s+.*)?$"
)
"""
Regex explanation for:
r"^\s*QM(\d+)\s+([A-DVXa-dvx?])\s+([\w\-_]+\.[\w.\-]+)\s*(\-|[\w\-]+\.[\w.\-]+)(\s+.*)?$"
r"^\s*QM(\d+)\s+([A-DVXa-dvx?])\s+([\w\-_]+\.[\w.\-]+)\s+(\-|[\w\-]+\.[\w.\-]+)(\s+.*)?$"
Purpose:
Matches a structured line beginning with "QM", followed by a numeric ID, a status/type code,
@@ -1654,7 +1654,7 @@ class LoadingSurvex:
This _should_ also check that the first QM survey point exists in the block in this survex file.
"""
qml = self.rx_qm0.match(comment) # checks for valid QM digit(s)
qml = self.rx_qm_digit.match(comment) # checks for valid QM digit(s)
if not qml:
message = f' ! QM Unrecognised QM number in "{survexblock.survexfile.path}" line:{comment}'
print(message)
@@ -1666,7 +1666,7 @@ 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)}" : regex failure typo?'
message = f' ! QM Unrecognised as valid in "{survexblock.survexfile.path}" QM{qml.group(1)=} "{qml.group(2)=}" : regex failure typo?'
print(message)
stash_data_issue(
parser="survex", message=message, url=None, sb=(survexblock.survexfile.path)
@@ -1695,8 +1695,8 @@ class LoadingSurvex:
self.LoadSurvexMessteam(survexblock, comment)
pass
qmcomment= self.rx_qm1.match(comment)
# rx_qm1 (r"(?i)^\s*QM(\w+)\s+(.+)$") QM followed by a word
qmcomment= self.rx_qm_detect.match(comment)
# rx_qm_detect (r"(?i)^\s*QM.*") QM fthen anything
if qmcomment:
self.ProcessQM(survexblock, qmcomment, comment)