From bf8bf7b3d2b1a1b07ae706acfdc414d2124f687a Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Mon, 16 Oct 2023 13:35:56 +0300 Subject: [PATCH] bug in getting cave slug --- core/views/wallets_edit.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/views/wallets_edit.py b/core/views/wallets_edit.py index af82acb..b578882 100644 --- a/core/views/wallets_edit.py +++ b/core/views/wallets_edit.py @@ -553,26 +553,32 @@ def walletedit(request, path=None): if not type(survex_paths) == list: # a string also is a sequence type, so do it this way survex_paths = [survex_paths] - for svxf in survex_paths: - if not svxf: # not a blank string + for svxfl in survex_paths: + if not svxfl: # not a blank string continue # print(f" - - {svxf=} ") - svx = Path(svxf) - if svx.suffix.lower() != ".svx": - svx = svx.with_suffix(".svx") - f = Path(settings.SURVEX_DATA) / svx + svxf = Path(svxfl) + if svxf.suffix.lower() != ".svx": + svxf = svx.with_suffix(".svx") + f = Path(settings.SURVEX_DATA) / svxf if not f.is_file(): + message = f"Specified survex file '{fpath}' in database not found on disc" + print(message) continue - fpath = svx.parent / svx.stem + fpath = svxf.parent / svxf.stem # print(f' - {fpath=}') try: svxfile = SurvexFile.objects.get(path=fpath) - + except: + message = f"Specified survex file '{fpath}'not found? database may be empty. Exception." + print(message) + # This failure will also get picked up by the "S" colour code red or orange + try: if svxfile.cave: caves.append(svxfile.cave) - cave_refs.append(svxfile.cave.reference()) # this is a string?! + cave_refs.append(svxfile.cave.slug()) # this is a string?! w, d, n, t = scan_survexblocks(svxfile) @@ -581,7 +587,7 @@ def walletedit(request, path=None): names.extend(n) team.extend(t) except: - message = "Specified survex file not found - database may be empty." + message = f"Exception wallet handling for {fpath} '{svxfile.cave}' " print(message) # This failure will also get picked up by the "S" colour code red or orange