2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-18 17:07:04 +00:00

now gets the wallet id from the .th files and links it in

This commit is contained in:
2025-10-24 22:02:33 +03:00
parent d9953d8bbe
commit 1968c099fe

View File

@@ -165,7 +165,10 @@ def findimportinsert(therionfile, imp):
rx_xth_me = re.compile(r"xth_me_image_insert.*{.*}$", re.MULTILINE)
rx_scrap = re.compile(r"^survey (\w*).*$", re.MULTILINE)
rx_input = re.compile(r"^input (\w*).*$", re.MULTILINE)
rx_input = re.compile(r"^input ", re.MULTILINE)
rx_line = re.compile(r"^line ", re.MULTILINE)
rx_ref = re.compile(r"^#?\s?ref\s*\:?\s*([^\s\t]*)", re.MULTILINE)
# ref:
def settherionfileinfo(filetuple):
@@ -186,10 +189,14 @@ def settherionfileinfo(filetuple):
# The equivalent for a tunnel 'path' would be a .th2 'line wall' or 'scrap'
# print(len(re.findall(r"line", ttext)))
if thtype == "th":
therionfile.npaths = len(re.findall(r"^input ", ttext, re.MULTILINE))
therionfile.npaths = len(rx_input.findall(ttext))
if wallet_texts := rx_ref.findall(ttext):
# print(f"#ref {therionfile.dwgname} : {wallet_text}")
if wallets := Wallet.objects.filter(walletname__in=wallet_texts): # ! Django idiom not used elsewhere. A filter using a list of strings.
for w in wallets:
therionfile.dwgwallets.add(w)
elif thtype == "th2":
therionfile.npaths = len(re.findall(r"^line ", ttext, re.MULTILINE))
therionfile.save()
therionfile.npaths = len(rx_line.findall(ttext))
# scan and look for survex blocks that might have been included, and image scans (as for tunnel drawings)
# which would populate dwgfile.survexfile
@@ -200,6 +207,7 @@ def settherionfileinfo(filetuple):
for xth_me in rx_xth_me.findall(ttext):
# WORK IN PROGRESS. Do not clutter up the DataIssues list with this
# Surely not needed for .th files ?? only .th2 ?
message = f"! Un-parsed image filename: {therionfile.dwgname} : {xth_me.split()[-3]} - {therionfile.dwgpath}"
# print(message)
# DataIssue.objects.create(parser='xTherion', message=message, url=f'/dwgdataraw/{therionfile.dwgpath}')
@@ -209,7 +217,9 @@ def settherionfileinfo(filetuple):
lg.write(message + "\n")
findwalletimage(therionfile, xth_me.split()[-3])
# print(f"{therionfile.dwgname} :{xth_me.split()[-3]}")
# therionfile.save()
for inp in rx_input.findall(ttext):
# if this 'input' is a .th2 file we have already seen, then we can assign this as a sub-file
# but we would need to disentangle to get the current path properly
@@ -285,6 +295,7 @@ def setdrwfileinfo(dwgfile):
"""
ff = Path(settings.DRAWINGS_DATA) / dwgfile.dwgpath
dwgfile.filesize = ff.stat().st_size
dwgfile.save()
if dwgfile.filesize <= 0:
message = f"! Zero length drawing file {ff}"
print(message)