2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Fixed bad import of surveyscans references from tunnel files

This commit is contained in:
Philip Sargent 2020-04-11 00:36:27 +01:00
parent 6aae9083c3
commit 79a31a41f9
2 changed files with 16 additions and 11 deletions

View File

@ -102,10 +102,10 @@ def reset():
import_logbooks()
import_QMs()
import_survex()
try:
import_tunnelfiles()
except:
print("Tunnel files parser broken.")
#try:
import_tunnelfiles()
#except:
# print("Tunnel files parser broken.")
import_surveys()

View File

@ -243,7 +243,7 @@ def LoadListScans():
def FindTunnelScan(tunnelfile, path):
scansfolder, scansfile = None, None
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg))$", path)
mscansdir = re.search(r"(\d\d\d\d#X?\d+\w?|1995-96kh|92-94Surveybookkh|1991surveybook|smkhs)/(.*?(?:png|jpg|pdf|jpeg))$", path)
if mscansdir:
scansfolderl = SurvexScansFolder.objects.filter(walletname=mscansdir.group(1))
if len(scansfolderl):
@ -252,9 +252,11 @@ def FindTunnelScan(tunnelfile, path):
if scansfolder:
scansfilel = scansfolder.survexscansingle_set.filter(name=mscansdir.group(2))
if len(scansfilel):
print(scansfilel, len(scansfilel))
print "ttt", tunnelfile.tunnelpath, path
assert len(scansfilel) == 1
if len(scansfilel) > 1:
print "BORK more than one image filename matches filter query. ", scansfilel[0]
print "BORK ", tunnelfile.tunnelpath, path
print "BORK ", mscansdir.group(1), mscansdir.group(2), len(scansfilel)
#assert len(scansfilel) == 1
scansfile = scansfilel[0]
if scansfolder:
@ -262,9 +264,9 @@ def FindTunnelScan(tunnelfile, path):
if scansfile:
tunnelfile.survexscans.add(scansfile)
elif path and not re.search(r"\.(?:png|jpg|jpeg)$(?i)", path):
elif path and not re.search(r"\.(?:png|jpg|pdf|jpeg)$(?i)", path):
name = os.path.split(path)[1]
print("ttt", tunnelfile.tunnelpath, path, name)
#print("debug-tunnelfileobjects ", tunnelfile.tunnelpath, path, name)
rtunnelfilel = TunnelFile.objects.filter(tunnelname=name)
if len(rtunnelfilel):
assert len(rtunnelfilel) == 1, ("two paths with name of", path, "need more discrimination coded")
@ -281,8 +283,11 @@ def SetTunnelfileInfo(tunnelfile):
fin = open(ff)
ttext = fin.read()
fin.close()
if tunnelfile.filesize <= 0:
print "DEBUG - zero length xml file", ff
return
mtype = re.search("<(fontcolours|sketch)", ttext)
assert mtype, ff
tunnelfile.bfontcolours = (mtype.group(1)=="fontcolours")
tunnelfile.npaths = len(re.findall("<skpath", ttext))