2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-13 23:37:08 +00:00

fixing resolved QM regex

This commit is contained in:
2025-07-25 16:06:26 +02:00
parent 3032386852
commit 29eae4e9b2
3 changed files with 38 additions and 10 deletions

View File

@@ -67,6 +67,7 @@ from troggle.parsers.imports import (
import_users, import_users,
import_QMs, import_QMs,
import_survex, import_survex,
import_justsurvex,
import_survex_checks, import_survex_checks,
import_surveyscans, import_surveyscans,
) )
@@ -240,6 +241,7 @@ class JobQueue:
"scans", "scans",
"drawings", "drawings",
"survex", "survex",
"justsurvex",
"test", "test",
"TOTAL" "TOTAL"
] ]
@@ -258,7 +260,7 @@ class JobQueue:
for a specified run in the history""" for a specified run in the history"""
total = 0 total = 0
for module in self.results_order: for module in self.results_order:
if module in ["runlabel", "date", "test", "TOTAL"]: if module in ["runlabel", "date", "test", "TOTAL", "justsurvex"]:
continue continue
# print(i, module, f"length={len(self.results[module])} ") # print(i, module, f"length={len(self.results[module])} ")
if self.results[module][i]: if self.results[module][i]:
@@ -447,6 +449,7 @@ def usage():
scans - the survey scans in all the wallets (must run before survex) scans - the survey scans in all the wallets (must run before survex)
drawings - read in the Tunnel & Therion files - which scans the survey scans too drawings - read in the Tunnel & Therion files - which scans the survey scans too
survex - read in the survex files - all the survex blocks and entrances x/y/z survex - read in the survex files - all the survex blocks and entrances x/y/z
justsurvex- read in and parse just the survex file (does not leave system in usable state)
survex_ck - set caves and people on wallets, check wallets for *ref survex_ck - set caves and people on wallets, check wallets for *ref
ents - read just the entrances x/y/z (must run after survex) ents - read just the entrances x/y/z (must run after survex)
@@ -527,6 +530,8 @@ if __name__ == "__main__":
jq.enq("scans", import_surveyscans) jq.enq("scans", import_surveyscans)
elif "survex" in sys.argv: elif "survex" in sys.argv:
jq.enq("survex", import_survex) jq.enq("survex", import_survex)
elif "justsurvex" in sys.argv:
jq.enq("justsurvex", import_justsurvex)
elif "loadpos" in sys.argv: elif "loadpos" in sys.argv:
jq.enq("survex", import_loadpos) jq.enq("survex", import_loadpos)
elif "drawings" in sys.argv: elif "drawings" in sys.argv:

View File

@@ -67,6 +67,15 @@ def import_survex():
with transaction.atomic(): with transaction.atomic():
troggle.parsers.locations.LoadPositions() troggle.parsers.locations.LoadPositions()
def import_justsurvex():
print("-- Importing Just Survex files")
with transaction.atomic():
import troggle.parsers.survex
print(" - Survex Blocks")
with transaction.atomic():
troggle.parsers.survex.LoadSurvexBlocks()
def import_survex_checks(): def import_survex_checks():
print(" - Survex: check wallet references and set persons, caves") print(" - Survex: check wallet references and set persons, caves")
with transaction.atomic(): with transaction.atomic():

View File

@@ -271,6 +271,7 @@ class LoadingSurvex:
rx_linelen = re.compile(r"[\d\-+.]+$") rx_linelen = re.compile(r"[\d\-+.]+$")
# this extensive list of expo roles are now (after 24/2/2025) just comments and not legal survex code. # this extensive list of expo roles are now (after 24/2/2025) just comments and not legal survex code.
# all now irrelevant as Olly restricted the list and survex now notices this.
roles = "(assistant|bitch|bodger|bolt|bolter|bolting|book|clino|comp|compass|consultant|disto|distox|distox2|" roles = "(assistant|bitch|bodger|bolt|bolter|bolting|book|clino|comp|compass|consultant|disto|distox|distox2|"
roles += "dog|dogsbody|drawing|drill|gps|helper|inst|instr|instrument|length|monkey|nagging|nail|" roles += "dog|dogsbody|drawing|drill|gps|helper|inst|instr|instrument|length|monkey|nagging|nail|"
roles += "nail_polish|nail_polish_bitch|nail_polish_monkey|nail_varnish|nail_varnish_bitch|note|notebook|" roles += "nail_polish|nail_polish_bitch|nail_polish_monkey|nail_varnish|nail_varnish_bitch|note|notebook|"
@@ -283,14 +284,7 @@ class LoadingSurvex:
rx_teamabs = re.compile(r"(?i)^\s*(" + roles + r")?(?:es|s)?\s*$") rx_teamabs = re.compile(r"(?i)^\s*(" + roles + r")?(?:es|s)?\s*$")
rx_teamone = re.compile(r"(?i)^\s*(.*)\s*$") rx_teamone = re.compile(r"(?i)^\s*(.*)\s*$")
rx_person = re.compile(r"(?i) and |/| / |, | , |&| & | \+ |^both$|^none$") rx_person = re.compile(r"(?i) and |/| / |, | , |&| & | \+ |^both$|^none$")
rx_qm = re.compile(
# r"(?i)^\s*QM(\d+)\s+(.+)\s+([\w\-\_]+)\.([\w\.\-]+)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$"
r"(?i)^\s*QM(\d+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\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).*$") rx_tapelng = re.compile(r"(?i).*(tape|length).*$")
rx_cave = re.compile(r"(?i)caves-(\d\d\d\d)/([-\d\w]+|\d\d\d\d-?\w+-\d+)") rx_cave = re.compile(r"(?i)caves-(\d\d\d\d)/([-\d\w]+|\d\d\d\d-?\w+-\d+)")
@@ -309,6 +303,17 @@ class LoadingSurvex:
rx_commteam = re.compile(r"(?i)\s*(Messteam|Zeichner|LUSS Dead Mountains)\s*[:]?(.*)") # non-expo survex files rx_commteam = re.compile(r"(?i)\s*(Messteam|Zeichner|LUSS Dead Mountains)\s*[:]?(.*)") # non-expo survex files
rx_quotedtitle = re.compile(r'(?i)^"(.*)"$') rx_quotedtitle = re.compile(r'(?i)^"(.*)"$')
# QM recognizers
# 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_qm = re.compile(
r"^\s*QM(\d+)\s+([A-DVXa-dvx?])\s+([\w\-\_]+\.)?(([\w\.\-]+))\s*(\-|([\w\-]+)(\.([\w\.\-]+))?)(\s+(.*))$"
)
# This regex matches a QM survey line where station identifiers and locations may be optional or placeholders.
""" """
Regular expression explanation for rx_starref (MS CoPilot) - Not actually USED any more ?! Regular expression explanation for rx_starref (MS CoPilot) - Not actually USED any more ?!
@@ -1626,9 +1631,18 @@ class LoadingSurvex:
which is a QM new declaration or a QM TICK closing declaration. which is a QM new declaration or a QM TICK closing declaration.
It _should_ recognise a non-numeric survey station ID, but currently doesn't. It _should_ recognise a non-numeric survey station ID, but currently doesn't.
Valid QM types are [a-dA-DvVxX?] A-D, V for Vertical, X for horrible and ? for unknown Valid QM types are [A-DvVxX?] A-D, V for Vertical, X for horrible and ? for unknown
""" """
# rx_qm : r"(?i)^\s*QM(\d+)\s+?(.+)\s+([\w\-\_]+)(\.([\w\.\-]+)?)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$) # rx_qm : r"(?i)^\s*QM(\d+)\s+?(.+)\s+([\w\-\_]+)(\.([\w\.\-]+)?)\s+(([\w\-]+)\.([\w\.\-]+)|\-)\s+(.+)$)
# This regex parses strings that start with "QM" followed by digits, then extracts several structured parts:
# (?i) : Case-insensitive matching
# ^\s* : Start of line, optional leading whitespace
# QM(\d+) : "QM" followed by a digit sequence (capture group 1)
# \s+?(.+) : Minimal spaces, then a descriptive text (capture group 2)
# \s+([\w\-_]+) : identifier prefix with word characters, hyphen or underscore (capture group 3)
# (\.([\w.\-]+)?) : identifier starting with a dot (capture group 4 and 5)
# \s+(([\w\-]+)\.([\w.\-]+)|\-?) : Either a pair of identifiers separated by a dot or an optional single dash (capture group 6, with 7 & 8 as subgroups)
# \s+(.+)$ : Remaining text at the end (e.g., comments or summary) (capture group 9)
qmline = self.rx_qm.match(comment) qmline = self.rx_qm.match(comment)
if qmline: if qmline:
self.LoadSurvexQM(survexblock, qmline) self.LoadSurvexQM(survexblock, qmline)