summaryrefslogtreecommitdiffstats
path: root/parsers/surveys.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2020-04-11 00:36:27 +0100
committerPhilip Sargent <philip.sargent@gmail.com>2020-04-11 00:36:27 +0100
commit79a31a41f979e8ae51b5f2a4a308542bf54a887e (patch)
tree77372df8640e9ec1a6641ce33fcf07badc8d24c1 /parsers/surveys.py
parent6aae9083c3ec1782da18cae36ed688f24616a3ef (diff)
downloadtroggle-79a31a41f979e8ae51b5f2a4a308542bf54a887e.tar.gz
troggle-79a31a41f979e8ae51b5f2a4a308542bf54a887e.tar.bz2
troggle-79a31a41f979e8ae51b5f2a4a308542bf54a887e.zip
Fixed bad import of surveyscans references from tunnel files
Diffstat (limited to 'parsers/surveys.py')
-rw-r--r--parsers/surveys.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/parsers/surveys.py b/parsers/surveys.py
index be8a368..9bd063d 100644
--- a/parsers/surveys.py
+++ b/parsers/surveys.py
@@ -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))