From 8f3b3295527ac76c20e11cf29a94895a4c7d6a17 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 5 Mar 2023 23:55:00 +0000 Subject: [PATCH] obscure bug empty directory inside empty directory --- core/views/survex.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/core/views/survex.py b/core/views/survex.py index e2a7309..e60df6e 100644 --- a/core/views/survex.py +++ b/core/views/survex.py @@ -30,10 +30,16 @@ but also displays data on a cave or caves when there is ambiguity todo = """- survexcavesingle is not properly producing any result for Homecoming, 1626-359, 2018-dm-07 even though there are dozens of surveys. +- REFACTOR the very impenetrable code for scanningsubdirectories, replace with modern python pathlib + +- filter out the non-public caves from display UNLESS LOGGED IN + - Never actual uses the object for the survexfile, works entirely from the filepath! Make it check and validate +- the primary survex file in each cave directory should be in a configuration, not buried in the code... + - Save the edited survexfile as a survexfile object and re-parse it, and update -all its dependencies + all its dependencies (work in progress) """ survexdatasetpath = Path(settings.SURVEX_DATA) @@ -452,8 +458,12 @@ def err(request, survex_file): def identifycavedircontents(gcavedir): - # find the primary survex file in each cave directory - # this should be in a configuration, not buried in the code... + """ + find the primary survex file in each cave directory + this should be in a configuration, not buried in the code... + + For gods sake someone refactor this monstrosity using pathlib + """ name = os.path.split(gcavedir)[1] subdirs = [] subsvx = [] @@ -508,6 +518,8 @@ def survexcaveslist(request): """This reads the entire list of caves in the Loser repo directory and produces a complete report. It can find caves which have not yet been properly registered in the system by Databasereset.py because someone may have uploaded the survex files without doing the rest of the integration process. + + It uses very impenetrable code in identifycavedircontents() """ # TO DO - filter out the non-public caves from display UNLESS LOGGED IN # This is very impenetrable code, original from Aaron Curtis I think. @@ -561,7 +573,10 @@ def survexcaveslist(request): subsurvdirs.append( (subdir, lsurvdirobj[0], lsurvdirobj[0:]) ) # list now includes the first item too - subdircaves.append((cavedir, (survdirobj[0], survdirobj[1:]), subsurvdirs)) + if survdirobj: + subdircaves.append((cavedir, (survdirobj[0], survdirobj[1:]), subsurvdirs)) + else: + print(f" ! Subdirectory containing empty subdirectory {subdirs} in {gcavedir}") # multifile caves elif len(survdirobj) > 1: