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

fixing new survex file editing

This commit is contained in:
2024-07-18 20:12:18 +02:00
parent ff08e05485
commit 5740a6b0d6
2 changed files with 126 additions and 40 deletions

View File

@@ -139,7 +139,7 @@ def get_survexfile(filename):
print(f"Number of SurvexFile objects found: {len(refs)}")
for s in refs:
print (s.path, s.primary, s.cave)
# print(type(survexfile), filename)
print(type(survexfile), filename)
return survexfile
class SvxForm(forms.Form):
@@ -165,7 +165,12 @@ class SvxForm(forms.Form):
self.survexfile = False
return survextemplatefile
if not self.survexfile:
self.survexfile = get_survexfile(self.data["filename"])
if sf := get_survexfile(self.data["filename"]): # walrus!
self.survexfile = sf
else:
print(">>> >>> WARNING - svx file not a SurvexFile object yet", fname, flush=True)
self.survexfile = fname
try:
fin = open(fname, "r", encoding="utf8", newline="")
svxtext = fin.read()
@@ -284,7 +289,7 @@ def svx(request, survex_file):
"""
warning = False
print(survex_file)
print(f"svx(): {survex_file=}")
if survex_file.lower().endswith(".svx"):
#cope with ".svx.svx" bollox
survex_file = survex_file[:-4]
@@ -344,7 +349,8 @@ def svx(request, survex_file):
form.data["code"] = rcode
# GET, also fall-through after POST-specific handling
svxfile = get_survexfile(survex_file)
if svxfile := get_survexfile(survex_file):
print(f"svx(): a real SurvexFile object {svxfile=} {svxfile.id=}")
if "code" not in form.data:
form.data["code"] = form.GetDiscCode()
@@ -377,6 +383,9 @@ def svx(request, survex_file):
except AttributeError: # some survexfiles just *include files and have no blocks themselves
svxblocksall = []
else:
svxfile = survex_file
print(f"svx(): NOT a real SurvexFile object '{svxfile=}'")
svxblocks = []
svxblocksall = []
svxlength = 0.0