From 3574dd4b1e4519cd29759d0ee93a5cec6b36b8a4 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 29 Jul 2020 22:54:53 +0100 Subject: [PATCH] Fix skipped import error messages for drawings --- parsers/surveys.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/parsers/surveys.py b/parsers/surveys.py index cbfa60e..eb24bc0 100644 --- a/parsers/surveys.py +++ b/parsers/surveys.py @@ -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,25 +126,24 @@ 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: tunnelfile.manyscansfolders.add(scansfolder) 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"