mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 18:37:18 +00:00
person attribution of surveyed length working
This commit is contained in:
@@ -36,7 +36,7 @@ class LoadingSurvex():
|
||||
A 'scansfolder' is what we today call a "survey scans folder" or a "wallet".
|
||||
"""
|
||||
|
||||
rx_flags = re.compile(r"not\s")
|
||||
rx_flagsnot= re.compile(r"not\s")
|
||||
rx_linelen = re.compile(r"[\d\-+.]+$")
|
||||
rx_team = re.compile(r"(?i)(Insts|Notes|Tape|Dog|Useless|Pics|Helper|Disto|Consultant)\s+(.*)$")
|
||||
rx_person = re.compile(r"(?i) and | / |, | & | \+ |^both$|^none$")
|
||||
@@ -76,6 +76,7 @@ class LoadingSurvex():
|
||||
depthinclude = 0
|
||||
legsnumberstack = []
|
||||
slengthstack = []
|
||||
personexpedstack = []
|
||||
stackbegin =[]
|
||||
flagsstack =[]
|
||||
datastack =[]
|
||||
@@ -95,6 +96,7 @@ class LoadingSurvex():
|
||||
currentsurvexfile = None
|
||||
currentcave = None
|
||||
caverndate = None
|
||||
currentpersonexped = []
|
||||
|
||||
def __init__(self):
|
||||
self.caveslist = GetCaveLookup()
|
||||
@@ -130,6 +132,7 @@ class LoadingSurvex():
|
||||
personrole.expeditionday = survexblock.expeditionday
|
||||
if personexpedition:
|
||||
personrole.person=personexpedition.person
|
||||
self.currentpersonexped.append(personexpedition)
|
||||
personrole.save()
|
||||
|
||||
def LoadSurvexEntrance(self, survexblock, line):
|
||||
@@ -200,10 +203,10 @@ class LoadingSurvex():
|
||||
ls = sline.lower().split()
|
||||
|
||||
# skip all splay legs
|
||||
if ls[datastar["from"]] == "..":
|
||||
if ls[datastar["from"]] == ".." or ls[datastar["from"]] == ".":
|
||||
#print("Splay in ", survexblock.survexfile.path)
|
||||
return
|
||||
if ls[datastar["to"]] == "..":
|
||||
if ls[datastar["to"]] == ".." or ls[datastar["to"]] == ".":
|
||||
#print("Splay in ", survexblock.survexfile.path)
|
||||
return
|
||||
if self.flagsstar["splayalias"]:
|
||||
@@ -441,10 +444,11 @@ class LoadingSurvex():
|
||||
self.flagsstar = copy.deepcopy(self.flagsdefault)
|
||||
flags = []
|
||||
|
||||
args = self.rx_flags.sub("not",args)
|
||||
args = self.rx_flagsnot.sub("not",args)
|
||||
argslist = args.split()
|
||||
for s in argslist:
|
||||
flags.append(s)
|
||||
print(" # flagslist:{}".format(flags),)
|
||||
|
||||
if "duplicate" in flags:
|
||||
self.flagsstar["duplicate"] = True
|
||||
@@ -460,7 +464,6 @@ class LoadingSurvex():
|
||||
if "notsplay" in flags:
|
||||
self.flagsstar["splay"] = False
|
||||
|
||||
|
||||
# if self.flagsstar["duplicate"] == True or self.flagsstar["surface"] == True or self.flagsstar["splay"] == True:
|
||||
# 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:
|
||||
@@ -664,6 +667,10 @@ class LoadingSurvex():
|
||||
print(" ", file=sys.stderr,end='')
|
||||
sys.stderr.flush()
|
||||
|
||||
def addpersonlengths():
|
||||
for personexpedition in self.currentpersonexped:
|
||||
personexpedition.legslength += self.slength
|
||||
|
||||
def printbegin():
|
||||
nonlocal blkid
|
||||
nonlocal pathlist
|
||||
@@ -700,6 +707,7 @@ class LoadingSurvex():
|
||||
# print("'{}' ".format(dict["type"].upper()), end="")
|
||||
# print("")
|
||||
# print("'{}' self.datastar ".format(self.datastar["type"].upper()))
|
||||
|
||||
# ------------ * FLAGS
|
||||
self.flagsstack.append(copy.deepcopy(self.flagsstar))
|
||||
# ------------ * FLAGS
|
||||
@@ -722,11 +730,12 @@ class LoadingSurvex():
|
||||
# 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 oldflags["skiplegs"] != self.flagsstar["skiplegs"]:
|
||||
print(" # POP 'any' flag now:'{}' was:{} ".format(self.flagsstar["skiplegs"], oldflags["skiplegs"]))
|
||||
|
||||
def starstatement(star):
|
||||
nonlocal survexblock
|
||||
@@ -747,10 +756,12 @@ class LoadingSurvex():
|
||||
self.stackbegin.append(blkid)
|
||||
self.legsnumberstack.append(self.legsnumber)
|
||||
self.slengthstack.append(self.slength)
|
||||
self.personexpedstack.append(self.currentpersonexped)
|
||||
pushblock()
|
||||
# PUSH state ++++++++++++++
|
||||
self.legsnumber = 0
|
||||
self.slength = 0.0
|
||||
self.currentpersonexped = []
|
||||
printbegin()
|
||||
newsurvexblock = models_survex.SurvexBlock(name=blkid, parent=survexblock,
|
||||
survexpath=pathlist,
|
||||
@@ -766,10 +777,11 @@ class LoadingSurvex():
|
||||
elif self.rx_end.match(cmd):
|
||||
survexblock.legsall = self.legsnumber
|
||||
survexblock.legslength = self.slength
|
||||
addpersonlengths()
|
||||
printend()
|
||||
slengthtotal += self.slength
|
||||
nlegstotal += self.legsnumber
|
||||
|
||||
|
||||
try:
|
||||
survexblock.parent.save() # django insists on this although it is already saved !?
|
||||
except:
|
||||
@@ -782,6 +794,7 @@ class LoadingSurvex():
|
||||
raise
|
||||
# POP state ++++++++++++++
|
||||
popblock()
|
||||
self.currentpersonexped = self.personexpedstack.pop()
|
||||
self.legsnumber = self.legsnumberstack.pop()
|
||||
self.slength = self.slengthstack.pop()
|
||||
blkid = self.stackbegin.pop()
|
||||
|
||||
Reference in New Issue
Block a user