summaryrefslogtreecommitdiffstats
path: root/parsers/surveys.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-04-27 20:44:24 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2021-04-27 20:44:24 +0100
commit5e478c7eb0a2bcd23ca46d1c4bd200750fbc9231 (patch)
tree5d6088d27a50dcf2b0a17ac863350f8d5100abc8 /parsers/surveys.py
parent821aaa1f66b003c34a8d568ff1dfdae057c17091 (diff)
downloadtroggle-5e478c7eb0a2bcd23ca46d1c4bd200750fbc9231.tar.gz
troggle-5e478c7eb0a2bcd23ca46d1c4bd200750fbc9231.tar.bz2
troggle-5e478c7eb0a2bcd23ca46d1c4bd200750fbc9231.zip
Imports in control panel work again
Diffstat (limited to 'parsers/surveys.py')
-rw-r--r--parsers/surveys.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/parsers/surveys.py b/parsers/surveys.py
index f9ca56a..5b7bc1e 100644
--- a/parsers/surveys.py
+++ b/parsers/surveys.py
@@ -14,8 +14,10 @@ from troggle.core.models.survex import SingleScan, Wallet, DrawingFile
from troggle.core.models.troggle import DataIssue
from troggle.core.utils import save_carefully
-'''Scans through all the :drawings: repository looking
+'''Searches through all the :drawings: repository looking
for tunnel and therion files
+
+Searches through all the survey scans directories in expofiles, looking for images to be referenced.
'''
@@ -41,7 +43,7 @@ def listdir(*directories):
return [folder.rstrip(r"/") for folder in folders]
-# handles url or file, so we can refer to a set of scans on another server
+# handles url or file, so we can refer to a set of scans (not drawings) on another server
def GetListDir(sdir):
res = [ ]
if sdir[:7] == "http://":
@@ -80,7 +82,7 @@ def LoadListScansFile(wallet):
# this iterates through the scans directories (either here or on the remote server)
# and builds up the models we can access later
-def LoadListScans():
+def load_all_scans():
print(' - Loading Survey Scans')
@@ -116,17 +118,18 @@ def LoadListScans():
wallet = Wallet(fpath=ff, walletname=f)
wallet.save()
LoadListScansFile(wallet)
-
-def find_tunnel_scan(dwgfile, path):
+ print("", flush=True)
+
+def find_tunnel_file(dwgfile, path):
'''Is given a line of text 'path' which may or may not contain a recognisable name of a scanned file
which we have already seen when we imported all the files we could find in the surveyscans direstories
'''
wallet, scansfile = None, None
- mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
+ mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg|gif))$", path)
if mscansdir:
scanswalletl = Wallet.objects.filter(walletname=mscansdir.group(1))
- # This should properly detect if a list of folders is returned and do something sensible, not just pick the first.
+ # This should be chnaged to properly detect if a list of folders is returned and do something sensible, not just pick the first.
if len(scanswalletl):
wallet = scanswalletl[0]
if len(scanswalletl) > 1:
@@ -148,7 +151,7 @@ def find_tunnel_scan(dwgfile, path):
if scansfile:
dwgfile.scans.add(scansfile)
- elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg|gif|pdf)$(?i)", path):
+ elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg|gif)$(?i)", path):
name = os.path.split(path)[1]
rdwgfilel = DrawingFile.objects.filter(dwgname=name)
if len(rdwgfilel):
@@ -248,7 +251,7 @@ def setdwgfileinfo(dwgfile):
# <pcarea area_signal="frame" sfscaledown="12.282584" sfrotatedeg="-90.76982" sfxtrans="11.676667377221136" sfytrans="-15.677173422877454" sfsketch="204description/scans/plan(38).png" sfstyle="" nodeconnzsetrelative="0.0">
for path, style in rx_pcpath.findall(ttext):
- find_tunnel_scan(dwgfile, path.decode())
+ find_tunnel_file(dwgfile, path.decode())
# should also scan and look for survex blocks that might have been included, and image scans
# which would populate dwgfile.survexfile