mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-01-19 09:22:32 +00:00
exploring recusrive behaviour
This commit is contained in:
parent
6bf762b72f
commit
dc5a53376d
@ -203,11 +203,9 @@ class Cave(TroggleModel):
|
||||
|
||||
def getCaveByReference(reference):
|
||||
areaname, code = reference.split("-", 1)
|
||||
#print(areaname, code)
|
||||
area = Area.objects.get(short_name = areaname)
|
||||
#print(area)
|
||||
foundCaves = list(Cave.objects.filter(area = area, kataster_number = code).all()) + list(Cave.objects.filter(area = area, unofficial_number = code).all())
|
||||
print((list(foundCaves)))
|
||||
#print((list(foundCaves)))
|
||||
if len(foundCaves) == 1:
|
||||
return foundCaves[0]
|
||||
else:
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user