From 5740a6b0d6ab584d405b258d36a17ea72a1d81ce Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Thu, 18 Jul 2024 20:12:18 +0200 Subject: fixing new survex file editing --- core/views/survex.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'core/views/survex.py') diff --git a/core/views/survex.py b/core/views/survex.py index d68ee41..83d9d79 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -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 -- cgit v1.2.3