mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-28 02:01:51 +00:00
Fix skipped import error messages for drawings
This commit is contained in:
parent
95b9daca80
commit
3574dd4b1e
@ -12,8 +12,6 @@ from utils import save_carefully
|
||||
from functools import reduce
|
||||
|
||||
import settings
|
||||
#from troggle.core.models import *
|
||||
#from troggle.core.models_caves import *
|
||||
from troggle.core.models_survex import SingleScan, ScansFolder, TunnelFile
|
||||
from troggle.core.models import DataIssue
|
||||
|
||||
@ -128,10 +126,9 @@ def FindTunnelScan(tunnelfile, path):
|
||||
scansfilel = scansfolder.singlescan_set.filter(name=mscansdir.group(2))
|
||||
if len(scansfilel):
|
||||
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
|
||||
message = "! More than one image filename matches filter query. [{}]: {} {} {} {}".format(scansfilel[0], mscansdir.group(1), mscansdir.group(2), tunnelfile.tunnelpath, path)
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='Drawings', message=message)
|
||||
scansfile = scansfilel[0]
|
||||
|
||||
if scansfolder:
|
||||
@ -139,14 +136,14 @@ def FindTunnelScan(tunnelfile, path):
|
||||
if scansfile:
|
||||
tunnelfile.scans.add(scansfile)
|
||||
|
||||
elif path and not re.search(rb"\.(?:png|jpg|pdf|jpeg)$(?i)", path):
|
||||
elif path and not re.search(rb"\.(?:png|jpg|pdf|jpeg|gif|pdf)$(?i)", path):
|
||||
name = os.path.split(path)[1]
|
||||
#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")
|
||||
message = "! Two paths with same name [{}]: {}".format(path, name)
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='Drawings', message=message)
|
||||
rtunnelfile = rtunnelfilel[0]
|
||||
#print "ttt", tunnelfile.tunnelpath, path, name, rtunnelfile.tunnelpath
|
||||
tunnelfile.tunnelcontains.add(rtunnelfile)
|
||||
|
||||
tunnelfile.save()
|
||||
@ -155,15 +152,16 @@ def FindTunnelScan(tunnelfile, path):
|
||||
def SetTunnelfileInfo(tunnelfile):
|
||||
ff = os.path.join(settings.TUNNEL_DATA, tunnelfile.tunnelpath)
|
||||
tunnelfile.filesize = os.stat(ff)[stat.ST_SIZE]
|
||||
if tunnelfile.filesize <= 0:
|
||||
message = "! Zero length xml file {}".format(ff)
|
||||
print(message)
|
||||
DataIssue.objects.create(parser='Drawings', message=message)
|
||||
return
|
||||
fin = open(ff,'rb')
|
||||
ttext = fin.read()
|
||||
fin.close()
|
||||
if tunnelfile.filesize <= 0:
|
||||
print("DEBUG - zero length xml file", ff)
|
||||
return
|
||||
mtype = re.search(rb"<(fontcolours|sketch)", ttext)
|
||||
|
||||
assert mtype, ff
|
||||
tunnelfile.bfontcolours = (mtype.group(1)=="fontcolours")
|
||||
tunnelfile.npaths = len(re.findall(rb"<skpath", ttext))
|
||||
tunnelfile.save()
|
||||
@ -174,7 +172,7 @@ def SetTunnelfileInfo(tunnelfile):
|
||||
FindTunnelScan(tunnelfile, path)
|
||||
|
||||
# should also scan and look for survex blocks that might have been included
|
||||
# and also survex titles as well.
|
||||
# which would populate tunnelfile.survexfile
|
||||
|
||||
tunnelfile.save()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user