mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-03-13 05:41:47 +00:00
move function (correctly this time)
This commit is contained in:
parent
ca6f7ed587
commit
c55716df08
@ -1,31 +0,0 @@
|
||||
2020 0 should be 0
|
||||
2019 20 should be 20
|
||||
2018 74 should be 74
|
||||
2017 60 should be 60
|
||||
2016 81 should be 81
|
||||
2015 79 should be 79
|
||||
2014 65 should be 65
|
||||
2013 51 should be 51
|
||||
2012 75 should be 75
|
||||
2011 68 should be 68
|
||||
2010 22 should be 22
|
||||
2009 52 should be 52
|
||||
2008 49 should be 49
|
||||
2007 111 should be 111
|
||||
2006 24 should be 24
|
||||
2005 55 should be 55
|
||||
2004 76 should be 76
|
||||
2003 40 should be 40
|
||||
2002 31 should be 31
|
||||
2001 48 should be 48
|
||||
2000 54 should be 54
|
||||
1999 79 should be 79
|
||||
1998 43 should be 43
|
||||
1997 53 should be 53
|
||||
1996 94 should be 94
|
||||
1995 41 should be 41
|
||||
1994 32 should be 32
|
||||
1993 41 should be 41
|
||||
1992 61 should be 61
|
||||
1991 38 should be 38
|
||||
1982 0 should be 0
|
@ -311,77 +311,6 @@ class LoadSurvex():
|
||||
if cave:
|
||||
survexfile.cave = cave
|
||||
|
||||
def RecursiveScan(self, survexblock, survexfile, fin, flinear):
|
||||
"""Follows the *include links in all the survex files from the root file 1623.svx
|
||||
and reads only the *import and *begin and *end statements. It produces a linearised
|
||||
list of the import tree
|
||||
"""
|
||||
indent = " " * self.depthimport
|
||||
sys.stderr.flush();
|
||||
self.callcount +=1
|
||||
if self.callcount % 10 ==0 :
|
||||
print(".", file=sys.stderr,end='')
|
||||
if self.callcount % 500 ==0 :
|
||||
print("\n", file=sys.stderr,end='')
|
||||
|
||||
self.svxfileslist.append(survexfile)
|
||||
|
||||
svxlines = fin.read().splitlines()
|
||||
for svxline in svxlines:
|
||||
self.lineno += 1
|
||||
sline, comment = self.rx_comment.match(svxline.strip()).groups()
|
||||
mstar = self.rx_star.match(sline)
|
||||
if mstar: # yes we are reading a *cmd
|
||||
cmd, args = mstar.groups()
|
||||
cmd = cmd.lower()
|
||||
if re.match("include$(?i)", cmd):
|
||||
includepath = os.path.normpath(os.path.join(os.path.split(survexfile.path)[0], re.sub(r"\.svx$", "", args)))
|
||||
path_match = re.search(r"caves-(\d\d\d\d)/(\d+|\d\d\d\d-?\w+-\d+)/", includepath)
|
||||
|
||||
includesurvexfile = models_survex.SurvexFile(path=includepath)
|
||||
|
||||
if includesurvexfile.exists():
|
||||
#--------------------------------------------------------
|
||||
self.depthimport += 1
|
||||
fininclude = includesurvexfile.OpenFile()
|
||||
flinear.write("{:2} {} *import {}\n".format(self.depthimport, indent, includesurvexfile.path))
|
||||
push = includesurvexfile.path.lower()
|
||||
self.stackimport.append(push)
|
||||
self.RecursiveScan(survexblock, includesurvexfile, fininclude, flinear)
|
||||
pop = self.stackimport.pop()
|
||||
if pop != push:
|
||||
print("!!!!!!! ERROR pop != push {} != {} {}".format(pop, push, self.stackimport))
|
||||
print("!!!!!!! ERROR pop != push {} != {} {}\n".format(pop, push, self.stackimport),file=flinear)
|
||||
print("!!!!!!! ERROR pop != push {} != {} {}".format(pop, push, self.stackimport),file=sys.stderr)
|
||||
flinear.write("{:2} {} *tropmi {}\n".format(self.depthimport, indent, includesurvexfile.path))
|
||||
fininclude.close()
|
||||
self.depthimport -= 1
|
||||
#--------------------------------------------------------
|
||||
else:
|
||||
print(" ! ERROR *include file not found for {}".format(includesurvexfile))
|
||||
elif re.match("begin$(?i)", cmd):
|
||||
self.depthbegin += 1
|
||||
depth = " " * self.depthbegin
|
||||
if args:
|
||||
pushargs = args
|
||||
else:
|
||||
pushargs = " "
|
||||
self.stackbegin.append(pushargs.lower())
|
||||
flinear.write(" {:2} {} *begin {}\n".format(self.depthbegin, depth, args))
|
||||
pass
|
||||
elif re.match("end$(?i)", cmd):
|
||||
depth = " " * self.depthbegin
|
||||
flinear.write(" {:2} {} *end {}\n".format(self.depthbegin, depth, args))
|
||||
if not args:
|
||||
args = " "
|
||||
popargs = self.stackbegin.pop()
|
||||
if popargs != args.lower():
|
||||
print("!!!!!!! ERROR BEGIN/END pop != push {} != {}\n{}".format(popargs, args, self. stackbegin))
|
||||
print("!!!!!!! ERROR BEGIN/END pop != push {} != {}\n{}\n".format(popargs, args, self. stackbegin), file=flinear)
|
||||
print(" !!!!!!! ERROR BEGIN/END pop != push {} != {}\n{}".format(popargs, args,self. stackbegin), file=sys.stderr,)
|
||||
|
||||
self.depthbegin -= 1
|
||||
pass
|
||||
|
||||
|
||||
def RecursiveLoad(self, survexblock, survexfile, fin):
|
||||
@ -522,8 +451,80 @@ class LoadSurvex():
|
||||
else:
|
||||
pass # ignore all other sorts of data
|
||||
|
||||
def RecursiveScan(self, survexblock, survexfile, fin, flinear):
|
||||
"""Follows the *include links in all the survex files from the root file 1623.svx
|
||||
and reads only the *import and *begin and *end statements. It produces a linearised
|
||||
list of the import tree
|
||||
"""
|
||||
indent = " " * self.depthimport
|
||||
sys.stderr.flush();
|
||||
self.callcount +=1
|
||||
if self.callcount % 10 ==0 :
|
||||
print(".", file=sys.stderr,end='')
|
||||
if self.callcount % 500 ==0 :
|
||||
print("\n", file=sys.stderr,end='')
|
||||
|
||||
def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
||||
self.svxfileslist.append(survexfile)
|
||||
|
||||
svxlines = fin.read().splitlines()
|
||||
for svxline in svxlines:
|
||||
self.lineno += 1
|
||||
sline, comment = self.rx_comment.match(svxline.strip()).groups()
|
||||
mstar = self.rx_star.match(sline)
|
||||
if mstar: # yes we are reading a *cmd
|
||||
cmd, args = mstar.groups()
|
||||
cmd = cmd.lower()
|
||||
if re.match("include$(?i)", cmd):
|
||||
includepath = os.path.normpath(os.path.join(os.path.split(survexfile.path)[0], re.sub(r"\.svx$", "", args)))
|
||||
path_match = re.search(r"caves-(\d\d\d\d)/(\d+|\d\d\d\d-?\w+-\d+)/", includepath)
|
||||
|
||||
includesurvexfile = models_survex.SurvexFile(path=includepath)
|
||||
|
||||
if includesurvexfile.exists():
|
||||
#--------------------------------------------------------
|
||||
self.depthimport += 1
|
||||
fininclude = includesurvexfile.OpenFile()
|
||||
flinear.write("{:2} {} *import {}\n".format(self.depthimport, indent, includesurvexfile.path))
|
||||
push = includesurvexfile.path.lower()
|
||||
self.stackimport.append(push)
|
||||
self.RecursiveScan(survexblock, includesurvexfile, fininclude, flinear)
|
||||
pop = self.stackimport.pop()
|
||||
if pop != push:
|
||||
print("!!!!!!! ERROR pop != push {} != {} {}".format(pop, push, self.stackimport))
|
||||
print("!!!!!!! ERROR pop != push {} != {} {}\n".format(pop, push, self.stackimport),file=flinear)
|
||||
print("!!!!!!! ERROR pop != push {} != {} {}".format(pop, push, self.stackimport),file=sys.stderr)
|
||||
flinear.write("{:2} {} *tropmi {}\n".format(self.depthimport, indent, includesurvexfile.path))
|
||||
fininclude.close()
|
||||
self.depthimport -= 1
|
||||
#--------------------------------------------------------
|
||||
else:
|
||||
print(" ! ERROR *include file not found for {}".format(includesurvexfile))
|
||||
elif re.match("begin$(?i)", cmd):
|
||||
self.depthbegin += 1
|
||||
depth = " " * self.depthbegin
|
||||
if args:
|
||||
pushargs = args
|
||||
else:
|
||||
pushargs = " "
|
||||
self.stackbegin.append(pushargs.lower())
|
||||
flinear.write(" {:2} {} *begin {}\n".format(self.depthbegin, depth, args))
|
||||
pass
|
||||
elif re.match("end$(?i)", cmd):
|
||||
depth = " " * self.depthbegin
|
||||
flinear.write(" {:2} {} *end {}\n".format(self.depthbegin, depth, args))
|
||||
if not args:
|
||||
args = " "
|
||||
popargs = self.stackbegin.pop()
|
||||
if popargs != args.lower():
|
||||
print("!!!!!!! ERROR BEGIN/END pop != push {} != {}\n{}".format(popargs, args, self. stackbegin))
|
||||
print("!!!!!!! ERROR BEGIN/END pop != push {} != {}\n{}\n".format(popargs, args, self. stackbegin), file=flinear)
|
||||
print(" !!!!!!! ERROR BEGIN/END pop != push {} != {}\n{}".format(popargs, args,self. stackbegin), file=sys.stderr,)
|
||||
|
||||
self.depthbegin -= 1
|
||||
pass
|
||||
|
||||
|
||||
def FindAndLoadAllSurvex(survexblockroot):
|
||||
"""Follows the *include links recursively to find files
|
||||
"""
|
||||
print(' - redirecting stdout to svxblks.log...')
|
||||
@ -532,6 +533,7 @@ def FindAndLoadAllSurvex(survexblockroot, survexfileroot):
|
||||
sys.stdout = open('svxblks.log', 'w')
|
||||
|
||||
print(' - SCANNING All Survex Blocks...',file=sys.stderr)
|
||||
survexfileroot = survexblockroot.survexfile
|
||||
|
||||
svxl0 = LoadSurvex()
|
||||
svxl0.callcount = 0
|
||||
@ -599,7 +601,7 @@ def LoadAllSurvexBlocks():
|
||||
|
||||
print(' - Loading All Survex Blocks...')
|
||||
memstart = models.get_process_memory()
|
||||
survexlegsnumber, survexlegsalllength = FindAndLoadAllSurvex(survexblockroot, survexfileroot)
|
||||
survexlegsnumber, survexlegsalllength = FindAndLoadAllSurvex(survexblockroot)
|
||||
memend = models.get_process_memory()
|
||||
print(" - MEMORY start:{:.3f} MB end:{:.3f} MB increase={:.3f} MB".format(memstart,memend, memend-memstart))
|
||||
|
||||
|
10971
svxblks.log
10971
svxblks.log
File diff suppressed because it is too large
Load Diff
6806
svxlinear.log
6806
svxlinear.log
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user