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:
@@ -165,7 +165,10 @@ def findimportinsert(therionfile, imp):
|
|||||||
|
|
||||||
rx_xth_me = re.compile(r"xth_me_image_insert.*{.*}$", re.MULTILINE)
|
rx_xth_me = re.compile(r"xth_me_image_insert.*{.*}$", re.MULTILINE)
|
||||||
rx_scrap = re.compile(r"^survey (\w*).*$", 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):
|
def settherionfileinfo(filetuple):
|
||||||
@@ -186,30 +189,37 @@ def settherionfileinfo(filetuple):
|
|||||||
# The equivalent for a tunnel 'path' would be a .th2 'line wall' or 'scrap'
|
# The equivalent for a tunnel 'path' would be a .th2 'line wall' or 'scrap'
|
||||||
# print(len(re.findall(r"line", ttext)))
|
# print(len(re.findall(r"line", ttext)))
|
||||||
if thtype == "th":
|
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":
|
elif thtype == "th2":
|
||||||
therionfile.npaths = len(re.findall(r"^line ", ttext, re.MULTILINE))
|
therionfile.npaths = len(rx_line.findall(ttext))
|
||||||
therionfile.save()
|
|
||||||
|
|
||||||
# scan and look for survex blocks that might have been included, and image scans (as for tunnel drawings)
|
# scan and look for survex blocks that might have been included, and image scans (as for tunnel drawings)
|
||||||
# which would populate dwgfile.survexfile
|
# which would populate dwgfile.survexfile
|
||||||
|
|
||||||
# in .th2 files:
|
# in .th2 files:
|
||||||
# ##XTHERION## xth_me_image_insert {500 1 1.0} {1700 {}} ../../../expofiles/surveyscans/2014/01popped_elev1.jpeg 0 {}
|
# ##XTHERION## xth_me_image_insert {500 1 1.0} {1700 {}} ../../../expofiles/surveyscans/2014/01popped_elev1.jpeg 0 {}
|
||||||
# scrap blownout -projection plan -scale [-81.0 -42.0 216.0 -42.0 0.0 0.0 7.5438 0.0 m]
|
# scrap blownout -projection plan -scale [-81.0 -42.0 216.0 -42.0 0.0 0.0 7.5438 0.0 m]
|
||||||
|
|
||||||
for xth_me in rx_xth_me.findall(ttext):
|
for xth_me in rx_xth_me.findall(ttext):
|
||||||
# WORK IN PROGRESS. Do not clutter up the DataIssues list with this
|
# WORK IN PROGRESS. Do not clutter up the DataIssues list with this
|
||||||
message = f"! Un-parsed image filename: {therionfile.dwgname} : {xth_me.split()[-3]} - {therionfile.dwgpath}"
|
# Surely not needed for .th files ?? only .th2 ?
|
||||||
# print(message)
|
message = f"! Un-parsed image filename: {therionfile.dwgname} : {xth_me.split()[-3]} - {therionfile.dwgpath}"
|
||||||
# DataIssue.objects.create(parser='xTherion', message=message, url=f'/dwgdataraw/{therionfile.dwgpath}')
|
# print(message)
|
||||||
# ! Un-parsed image filename: 107coldest : ../../../expofiles/surveyscans/2015/2015#20/notes.jpg - therion/plan/107coldest.th2
|
# DataIssue.objects.create(parser='xTherion', message=message, url=f'/dwgdataraw/{therionfile.dwgpath}')
|
||||||
|
# ! Un-parsed image filename: 107coldest : ../../../expofiles/surveyscans/2015/2015#20/notes.jpg - therion/plan/107coldest.th2
|
||||||
|
|
||||||
with open("therionrefs.log", "a") as lg:
|
with open("therionrefs.log", "a") as lg:
|
||||||
lg.write(message + "\n")
|
lg.write(message + "\n")
|
||||||
|
|
||||||
findwalletimage(therionfile, xth_me.split()[-3])
|
findwalletimage(therionfile, xth_me.split()[-3])
|
||||||
|
# print(f"{therionfile.dwgname} :{xth_me.split()[-3]}")
|
||||||
|
|
||||||
|
# therionfile.save()
|
||||||
for inp in rx_input.findall(ttext):
|
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
|
# 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
|
# 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
|
ff = Path(settings.DRAWINGS_DATA) / dwgfile.dwgpath
|
||||||
dwgfile.filesize = ff.stat().st_size
|
dwgfile.filesize = ff.stat().st_size
|
||||||
|
dwgfile.save()
|
||||||
if dwgfile.filesize <= 0:
|
if dwgfile.filesize <= 0:
|
||||||
message = f"! Zero length drawing file {ff}"
|
message = f"! Zero length drawing file {ff}"
|
||||||
print(message)
|
print(message)
|
||||||
|
|||||||
Reference in New Issue
Block a user