2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 17:37:10 +00:00

exploring recusrive behaviour

This commit is contained in:
Philip Sargent
2020-06-24 02:33:43 +01:00
parent 6bf762b72f
commit dc5a53376d
2 changed files with 8 additions and 5 deletions

View File

@@ -162,7 +162,7 @@ def RecursiveLoad(survexblock, survexfile, fin):
global callcount
global survexlegsnumber
print(insp+" - MEM:{} Reading. parent:{} <> {} ".format(get_process_memory(),survexblock.survexfile.path,survexfile.path))
print(insp+" - MEM:{:.3f} Reading. parent:{} <> {} ".format(get_process_memory(),survexblock.survexfile.path,survexfile.path))
stamp = datetime.now()
lineno = 0
@@ -181,6 +181,8 @@ def RecursiveLoad(survexblock, survexfile, fin):
survexfile.cave = cave
svxlines = ''
svxlines = fin.read().splitlines()
# cannot close file now as it may be recursively called with the same file id fin if nested *begin
# occurs.
for svxline in svxlines:
lineno += 1
# break the line at the comment
@@ -341,20 +343,23 @@ def RecursiveLoad(survexblock, survexfile, fin):
survexblockdown.save()
survexblock.save()
survexblock = survexblockdown
print(insp+" - ENTERING nested *begin/*end block: {}".format(name))
insp += "> "
RecursiveLoad(survexblockdown, survexfile, fin)
#--------------------------------------------------------
# do not close the file as there may be more blocks in this one
# and it is re-read afresh with every nested begin-end block.
insp = insp[2:]
else:
iblankbegins += 1
elif re.match("end$(?i)", cmd):
if iblankbegins:
print(insp+" - RETURNING from nested *begin/*end block: {}".format(line))
iblankbegins -= 1
else:
legsinblock = survexlegsnumber - previousnlegs
print(insp+"LEGS: {} (previous: {}, now:{})".format(legsinblock,previousnlegs,survexlegsnumber))
print(insp+" - LEGS: {} (previous: {}, now:{})".format(legsinblock,previousnlegs,survexlegsnumber))
survexblock.legsall = legsinblock
survexblock.save()
endstamp = datetime.now()