summaryrefslogtreecommitdiffstats
path: root/parsers/survex.py
diff options
context:
space:
mode:
Diffstat (limited to 'parsers/survex.py')
-rw-r--r--parsers/survex.py33
1 files changed, 18 insertions, 15 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index 681dc48..ef69759 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -1165,33 +1165,34 @@ class LoadingSurvex:
def IdentifyCave(self, cavepath, svxid, depth):
"""Given a file path for a survex file, e.g. /1626/107/107.svx, or a survex-block path,
- return the cave object
-
- REWRITE ALL THIS and make a methoid on the class
+ return the cave object
"""
- caveslist = GetCaveLookup()
- if cavepath.lower() in caveslist: # will only work after we load in full paths as indexes, see below
- return caveslist[cavepath.lower()]
+ path = cavepath.lower()
+ if path in self.caveslist: # primed with GCaveLookup
+ return self.caveslist[path]
# rx_cave = re.compile(r"(?i)caves-(\d\d\d\d)/([-\d\w]+|\d\d\d\d-?\w+-\d+)")
- path_match = self.rx_cave.search(cavepath) # use as Class method.
+ path_match = self.rx_cave.search(cavepath)
if path_match:
sluggy = f"{path_match.group(1)}-{path_match.group(2)}"
- # guesses = [sluggy.lower(), path_match.group(2).lower()] # this looks for JUST "107" and ignores 1626..
guesses = [sluggy.lower()] # full 1626-107 search, don;t use short-forms
for g in guesses:
- if g in caveslist:
- caveslist[cavepath] = caveslist[g] # set "caves-1626/107/107.svx" as index to cave 1626-107
- return caveslist[g]
- print(f" ! Failed to find cave for {cavepath.lower()}", file=sys.stderr)
+ if g in self.caveslist:
+ self.caveslist[cavepath] = self.caveslist[g] # set "caves-1626/107/107" as index to cave 1626-107
+ return self.caveslist[g]
+ cave = create_new_cave(cavepath) # uses the pending stuff to create pending cave descriptions
+ self.caveslist[cavepath] = cave
+ message = f" ! MAKING cave for {cavepath=} {svxid=}"
+ stash_data_issue(parser="survex", message=message, url=None, sb=(svxid))
+ if not cavepath.startswith("caves-1624") or cavepath.startswith("caves-1626"):
+ print(message, file=sys.stderr)
else:
- # not a cave, but that is fine.
- if self.is_it_already_pending(cavepath, svxid, depth):
+ # isn't all this pointless...??
+ if self.is_it_already_pending(cavepath, svxid, depth): # but pending will already have been created as Cave objects
pass
else:
# It is too late to add it to the pending caves list here, they were already
# processed in parsers/caves.py So we have to do a bespoke creation.
cave = create_new_cave(svxid)
-
message = f" ! Warning: cave identifier '{caveid}'or {id} (guessed from file path) is not a known cave. Need to add to expoweb/cave_data/pendingcaves.txt ? In '{includelabel}.svx' at depth:[{len(depth)}]."
print("\n" + message)
print("\n" + message, file=sys.stderr)
@@ -1238,6 +1239,8 @@ class LoadingSurvex:
if id in self.pending:
print(f"! ALREADY PENDING id {id}", file=sys.stderr)
return True
+
+ return False
def LoadSurvexFile(self, svxid):
"""Creates SurvexFile in the database, and SurvexDirectory if needed