2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

per svxfile debug printing enabled

This commit is contained in:
Philip Sargent 2020-07-06 21:46:19 +01:00
parent d2833d26cc
commit d27a74c97b

View File

@ -22,6 +22,9 @@ from troggle.core.views_caves import MapLocations
survexblockroot = None
ROOTBLOCK = "rootblock"
debugprint = False # Turns on debug printout for just one *include file
debugprinttrigger = "caves-1623/40/old/EisSVH"
class SurvexLeg():
"""No longer a models.Model subclass, so no longer a database table
"""
@ -177,10 +180,12 @@ class LoadingSurvex():
invalid_tape = 0.0
if self.flagsstar["skiplegs"]:
#print("skip in ", self.flagsstar, survexblock.survexfile.path)
if debugprint:
print("skip in ", self.flagsstar, survexblock.survexfile.path)
return
#print("! LEG datastar type:{}++{}\n{} ".format(self.datastar["type"].upper(), survexblock.survexfile.path, sline))
if debugprint:
print("! LEG datastar type:{}++{}\n{} ".format(self.datastar["type"].upper(), survexblock.survexfile.path, sline))
# SKIP PASSAGES *data passage
if self.datastar["type"] == "passage":
return
@ -204,17 +209,21 @@ class LoadingSurvex():
# skip all splay legs
if ls[datastar["from"]] == ".." or ls[datastar["from"]] == ".":
#print("Splay in ", survexblock.survexfile.path)
if debugprint:
print("Splay in ", survexblock.survexfile.path)
return
if ls[datastar["to"]] == ".." or ls[datastar["to"]] == ".":
#print("Splay in ", survexblock.survexfile.path)
if debugprint:
print("Splay in ", survexblock.survexfile.path)
return
if self.flagsstar["splayalias"]:
if ls[datastar["from"]] == "-":
#print("Aliased splay in ", survexblock.survexfile.path)
if debugprint:
print("Aliased splay in ", survexblock.survexfile.path)
return
if ls[datastar["to"]] == "-":
#print("Aliased splay in ", survexblock.survexfile.path)
if debugprint:
print("Aliased splay in ", survexblock.survexfile.path)
return
try:
@ -298,7 +307,7 @@ class LoadingSurvex():
refline = self.rx_ref_text.match(args)
if refline:
# a textual reference such as "1996-1999 Not-KH survey book pp 92-95"
print(self.insp+ "*REF quoted text so ignored:"+ args)
# print(self.insp+ "*REF quoted text so ignored:"+ args)
return
if len(args)< 4:
@ -448,7 +457,8 @@ class LoadingSurvex():
argslist = args.split()
for s in argslist:
flags.append(s)
print(" # flagslist:{}".format(flags),)
if debugprint:
print(" ^ flagslist:{}".format(flags),)
if "duplicate" in flags:
self.flagsstar["duplicate"] = True
@ -468,6 +478,9 @@ class LoadingSurvex():
# actually we do want to count duplicates as this is for "effort expended in surveying underground"
if self.flagsstar["surface"] == True or self.flagsstar["splay"] == True:
self.flagsstar["skiplegs"] = True
if debugprint:
print(" $ flagslist:{}".format(flags),)
def IdentifyCave(self, cavepath):
if cavepath.lower() in self.caveslist:
@ -521,10 +534,11 @@ class LoadingSurvex():
Creates a new current survexfile and valid .survexdirectory
The survexblock passed-in is not necessarily the parent. FIX THIS.
"""
# print(" # datastack in LoadSurvexFile:{} 'type':".format(svxid), end="")
# for dict in self.datastack:
# print("'{}' ".format(dict["type"].upper()), end="")
# print("")
if debugprint:
print(" # datastack in LoadSurvexFile:{} 'type':".format(svxid), end="")
for dict in self.datastack:
print("'{}' ".format(dict["type"].upper()), end="")
print("")
depth = " " * self.depthbegin
@ -566,23 +580,30 @@ class LoadingSurvex():
print(newdirectory.primarysurvexfile, file=sys.stderr)
raise
# print(" # datastack end LoadSurvexFile:{} 'type':".format(svxid), end="")
# for dict in self.datastack:
# print("'{}' ".format(dict["type"].upper()), end="")
# print("")
pass
if debugprint:
print(" # datastack end LoadSurvexFile:{} 'type':".format(svxid), end="")
for dict in self.datastack:
print("'{}' ".format(dict["type"].upper()), end="")
print("")
def ProcessIncludeLine(self, included):
global debugprint
svxid = included.groups()[0]
if svxid.lower() == debugprinttrigger.lower():
debugprint = True
self.LoadSurvexFile(svxid)
self.stacksvxfiles.append(self.currentsurvexfile)
def ProcessEdulcniLine(self, edulcni):
"""Saves the current survexfile in the db
"""
global debugprint
svxid = edulcni.groups()[0]
#depth = " " * self.depthbegin
#print("{:2}{} - Edulcni survexfile:'{}'".format(self.depthbegin, depth, svxid))
if debugprint:
depth = " " * self.depthbegin
print("{:2}{} - Edulcni survexfile:'{}'".format(self.depthbegin, depth, svxid))
if svxid.lower() == debugprinttrigger.lower():
debugprint = False
self.currentsurvexfile.save()
self.currentsurvexfile = self.stacksvxfiles.pop()
@ -667,9 +688,9 @@ class LoadingSurvex():
print(" ", file=sys.stderr,end='')
sys.stderr.flush()
def addpersonlengths():
for personexpedition in self.currentpersonexped:
personexpedition.legslength += self.slength
# def addpersonlengths():
# for personexpedition in self.currentpersonexped:
# personexpedition.legslength += self.slength
def printbegin():
nonlocal blkid
@ -693,20 +714,21 @@ class LoadingSurvex():
def pushblock():
nonlocal blkid
# print(" # datastack at 1 *begin {} 'type':".format(blkid), end="")
# for dict in self.datastack:
# print("'{}' ".format(dict["type"].upper()), end="")
# print("")
# print("'{}' self.datastar ".format(self.datastar["type"].upper()))
if debugprint:
print(" # datastack at 1 *begin {} 'type':".format(blkid), end="")
for dict in self.datastack:
print("'{}' ".format(dict["type"].upper()), end="")
print("")
print("'{}' self.datastar ".format(self.datastar["type"].upper()))
# ------------ * DATA
self.datastack.append(copy.deepcopy(self.datastar))
# ------------ * DATA
# print(" # datastack at 2 *begin {} 'type':".format(blkid), end="")
# for dict in self.datastack:
# print("'{}' ".format(dict["type"].upper()), end="")
# print("")
# print("'{}' self.datastar ".format(self.datastar["type"].upper()))
if debugprint:
print(" # datastack at 2 *begin {} 'type':".format(blkid), end="")
for dict in self.datastack:
print("'{}' ".format(dict["type"].upper()), end="")
print("")
print("'{}' self.datastar ".format(self.datastar["type"].upper()))
# ------------ * FLAGS
self.flagsstack.append(copy.deepcopy(self.flagsstar))
@ -716,26 +738,28 @@ class LoadingSurvex():
def popblock():
nonlocal blkid
nonlocal oldflags
# print(" # datastack at *end '{} 'type':".format(blkid), end="")
# for dict in self.datastack:
# print("'{}' ".format(dict["type"].upper()), end="")
# print("")
# print("'{}' self.datastar ".format(self.datastar["type"].upper()))
if debugprint:
print(" # datastack at *end '{} 'type':".format(blkid), end="")
for dict in self.datastack:
print("'{}' ".format(dict["type"].upper()), end="")
print("")
print("'{}' self.datastar ".format(self.datastar["type"].upper()))
# ------------ * DATA
self.datastar = copy.deepcopy(self.datastack.pop())
# ------------ * DATA
# print(" # datastack after *end '{} 'type':".format(blkid), end="")
# for dict in self.datastack:
# print("'{}' ".format(dict["type"].upper()), end="")
# print("")
# print("'{}' self.datastar ".format(self.datastar["type"].upper()))
if debugprint:
print(" # datastack after *end '{} 'type':".format(blkid), end="")
for dict in self.datastack:
print("'{}' ".format(dict["type"].upper()), end="")
print("")
print("'{}' self.datastar ".format(self.datastar["type"].upper()))
# ------------ * FLAGS
self.flagsstar = copy.deepcopy(self.flagsstack.pop())
# ------------ * FLAGS
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
print(" # POP 'any' flag now:'{}' was:{} ".format(self.flagsstar["skiplegs"], oldflags["skiplegs"]))
if debugprint:
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
print(" # POP 'any' flag now:'{}' was:{} ".format(self.flagsstar["skiplegs"], oldflags["skiplegs"]))
def starstatement(star):
nonlocal survexblock
@ -777,7 +801,6 @@ class LoadingSurvex():
elif self.rx_end.match(cmd):
survexblock.legsall = self.legsnumber
survexblock.legslength = self.slength
addpersonlengths()
printend()
slengthtotal += self.slength
nlegstotal += self.legsnumber
@ -816,8 +839,9 @@ class LoadingSurvex():
elif self.rx_flags.match(cmd):
oldflags = self.flagsstar
self.LoadSurvexFlags(args)
# if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
# print(" # CHANGE 'any' flag now:'{}' was:{} ".format(self.flagsstar["skiplegs"], oldflags["skiplegs"]))
if debugprint:
if oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
print(" # CHANGE 'any' flag now:'{}' was:{} ".format(self.flagsstar["skiplegs"], oldflags["skiplegs"]))
elif self.rx_data.match(cmd):
self.LoadSurvexDataCmd(survexblock, args)