diff options
author | Philip Sargent <philip.sargent@gmail.com> | 2023-09-06 21:38:45 +0300 |
---|---|---|
committer | Philip Sargent <philip.sargent@gmail.com> | 2023-09-06 21:38:45 +0300 |
commit | 1ddb8248dff14b819c0037b9f59d68aedeba9829 (patch) | |
tree | 8f6fa3a4b412844598b4c99f6cbf854e2fca64f6 /parsers/survex.py | |
parent | 0dc0e275193457d1875ca1690168112a61b4bca4 (diff) | |
download | troggle-1ddb8248dff14b819c0037b9f59d68aedeba9829.tar.gz troggle-1ddb8248dff14b819c0037b9f59d68aedeba9829.tar.bz2 troggle-1ddb8248dff14b819c0037b9f59d68aedeba9829.zip |
SUrvexDirectory no longer necessary
Diffstat (limited to 'parsers/survex.py')
-rw-r--r-- | parsers/survex.py | 81 |
1 files changed, 44 insertions, 37 deletions
diff --git a/parsers/survex.py b/parsers/survex.py index ba2622c..e802a79 100644 --- a/parsers/survex.py +++ b/parsers/survex.py @@ -332,9 +332,10 @@ class LoadingSurvex: stacksvxfiles = [] svxfileslist = [] svxdirs = {} + svxprim = {} uniquefile = {} # each key is a survex path, and its value is a list of parent files expos = {} - survexdict = {} # each key is a directory, and its value is a list of files + #survexdict = {} # each key is a directory, and its value is a list of files lineno = 0 insp = "" callcount = 0 @@ -1175,19 +1176,25 @@ class LoadingSurvex: are doing. """ + # all = SurvexDirectory.objects.all() + # if not all: + # sd0 = SurvexDirectory(path=headpath, primarysurvexfile=self.currentsurvexfiley) + # sd0 = SurvexDirectory.objects.filter(id=1)[0] + if not headpath: # This is normal for .svx file in the root of the :loser: repo # message = f" ! GetSurvexDirectory NO headpath given at {self.currentsurvexfile}" # print("\n"+message,file=sys.stderr) # stash_data_issue(parser="survex", message=message, url=f"/survexfile/{self.currentsurvexfile}") - return self.svxdirs[""], self.currentsurvexfile + return self.currentsurvexfile - if headpath.lower() not in self.svxdirs: + if headpath.lower() not in self.svxprim: primary = self.currentsurvexfile - self.svxdirs[headpath.lower()] = SurvexDirectory(path=headpath, primarysurvexfile=primary) # NOT .lower() - self.svxdirs[headpath.lower()].save() - self.survexdict[self.svxdirs[headpath.lower()]] = [] # list of the files in the directory - return self.svxdirs[headpath.lower()], self.svxdirs[headpath.lower()].primarysurvexfile + # self.svxdirs[headpath.lower()] = sd0 #SurvexDirectory(path=headpath, primarysurvexfile=primary) # NOT .lower() + # self.svxdirs[headpath.lower()].save() + self.svxprim[headpath.lower()] = primary + #self.survexdict[self.svxdirs[headpath.lower()]] = [] # list of the files in the directory + return self.svxprim[headpath.lower()] def ReportNonCaveIncludes(self, headpath, includelabel, depth): """Ignore surface, kataser and gpx *include survex files""" @@ -1278,17 +1285,17 @@ class LoadingSurvex: newfile.save() # until we do this there is no internal id so no foreign key works self.currentsurvexfile = newfile - newdirectory, primary = self.GetSurvexDirectory(headpath) - newdirectory.save() - newfile.survexdirectory = newdirectory - self.survexdict[newdirectory].append(newfile) + primary = self.GetSurvexDirectory(headpath) + #newdirectory.save() + #newfile.survexdirectory = newdirectory + #self.survexdict[newdirectory].append(newfile) newfile.primary = primary - if not newdirectory: - message = f" ! 'None' SurvexDirectory returned from GetSurvexDirectory({headpath})" - print(message) - print(message, file=sys.stderr) - stash_data_issue(parser="survex", message=message, url=f"/survexfile/{svxid}") + # if not newdirectory: + # message = f" ! 'None' SurvexDirectory returned from GetSurvexDirectory({headpath})" + # print(message) + # print(message, file=sys.stderr) + # stash_data_issue(parser="survex", message=message, url=f"/survexfile/{svxid}") # REPLACE all this IdentifyCave() stuff with GCaveLookup ? cave = IdentifyCave(headpath) # cave already exists in db @@ -1302,23 +1309,23 @@ class LoadingSurvex: newfile.cave = cave # print(f"\n - New directory '{newdirectory}' for cave '{cave}'",file=sys.stderr) - if not newfile.survexdirectory: - message = f" ! .survexdirectory NOT SET in new SurvexFile {svxid} " - print(message) - print(message, file=sys.stderr) - stash_data_issue(parser="survex", message=message) + # if not newfile.survexdirectory: + # message = f" ! .survexdirectory NOT SET in new SurvexFile {svxid} " + # print(message) + # print(message, file=sys.stderr) + # stash_data_issue(parser="survex", message=message) if not newfile.primary: message = f" ! .primary NOT SET in new SurvexFile {svxid} " print(message) print(message, file=sys.stderr) stash_data_issue(parser="survex", message=message) self.currentsurvexfile.save() # django insists on this although it is already saved !? - try: - newdirectory.save() - except: - print(newdirectory, file=sys.stderr) - print(newdirectory.primarysurvexfile, file=sys.stderr) - raise + # try: + # newdirectory.save() + # except: + # print(newdirectory, file=sys.stderr) + # print(newdirectory.primarysurvexfile, file=sys.stderr) + # raise def ProcessIncludeLine(self, included): @@ -2311,9 +2318,9 @@ def FindAndLoadSurvex(survexblockroot): print("\n - Loading All Survex Blocks (LinearLoad)", file=sys.stderr) svx_load = LoadingSurvex() - svx_load.survexdict[survexfileroot.survexdirectory] = [] - svx_load.survexdict[survexfileroot.survexdirectory].append(survexfileroot) - svx_load.svxdirs[""] = survexfileroot.survexdirectory + #svx_load.survexdict[survexfileroot.survexdirectory] = [] + #svx_load.survexdict[survexfileroot.survexdirectory].append(survexfileroot) + #svx_load.svxdirs[""] = survexfileroot.survexdirectory # pr2 = cProfile.Profile() # pr2.enable() @@ -2339,10 +2346,10 @@ def FindAndLoadSurvex(survexblockroot): legsnumber = svx_load.legsnumber mem1 = get_process_memory() - print(f" - Number of SurvexDirectories: {len(svx_load.survexdict):,}") + print(f" - Number of SurvexDirectories: {len(svx_load.svxprim):,}") tf = 0 - for d in svx_load.survexdict: - tf += len(svx_load.survexdict[d]) + # for d in svx_load.survexdict: + # tf += len(svx_load.survexdict[d]) print(f" - Number of SurvexFiles: {tf:,}") print(f" - Number of Survex legs: {legsnumber:,}") svx_load = None @@ -2402,9 +2409,9 @@ def parse_one_file(fpath): # --------------------------------------in progress-- print(f" - block_dummy now '{block_dummy}' {type(block_dummy)} id={block_dummy.id} f:{block_dummy.survexfile}") - svx_load.survexdict[svxfileroot.survexdirectory] = [] - svx_load.survexdict[svxfileroot.survexdirectory].append(svxfileroot) - svx_load.svxdirs[""] = svxfileroot.survexdirectory + # svx_load.survexdict[svxfileroot.survexdirectory] = [] + # svx_load.survexdict[svxfileroot.survexdirectory].append(svxfileroot) + #svx_load.svxdirs[""] = svxfileroot.survexdirectory # ---------------------------------------------------------------- svx_load.LinearLoad(block_dummy, svxfileroot.path, fname) @@ -2418,7 +2425,7 @@ def parse_one_file(fpath): # --------------------------------------in progress-- global svx_load print(f"\n - Loading One Survex file '{fpath}'", file=sys.stderr) svx_load = LoadingSurvex() - svx_load.survexdict = {} + #svx_load.survexdict = {} fname = Path(settings.SURVEX_DATA, (fpath + ".svx")) |