summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-07-18 20:12:18 +0200
committerPhilip Sargent <philip.sargent@gmail.com>2024-07-18 20:12:18 +0200
commit5740a6b0d6ab584d405b258d36a17ea72a1d81ce (patch)
treeb3a21879edbf0fd4319b1b9b02bc0c369d937044 /core
parentff08e05485f7bc05701e0923f972acad38bfbf8e (diff)
downloadtroggle-5740a6b0d6ab584d405b258d36a17ea72a1d81ce.tar.gz
troggle-5740a6b0d6ab584d405b258d36a17ea72a1d81ce.tar.bz2
troggle-5740a6b0d6ab584d405b258d36a17ea72a1d81ce.zip
fixing new survex file editing
Diffstat (limited to 'core')
-rw-r--r--core/views/survex.py17
1 files changed, 13 insertions, 4 deletions
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