2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 21:47:12 +00:00

finding the right survex file for a cave

This commit is contained in:
2023-09-15 22:41:40 +03:00
parent 3390f17aa4
commit a8d4b05617
2 changed files with 50 additions and 20 deletions

View File

@@ -1170,8 +1170,10 @@ class LoadingSurvex:
fixedpts/gps
and everything at top level, directly in caves-1623/ not in a subdir
NOTE self.cavelist is a superset of GCaveLookup, which already contians both uppercase and lowercase aliases
why is this called with cavepath="caves-1623/2023-kt-02" when this is a cave where the files are in "caves-1623/2023-kt-02/"
"""
if cavepath == "caves-1623/99ob02":
if cavepath == "caves-1623/99ob02": # nothing special about this cave, just used as a marker to dump the cavelist to file
for key in self.caveslist:
cave = self.caveslist[key]
if type(cave) != Cave:
@@ -1185,8 +1187,8 @@ class LoadingSurvex:
message = (f" - {cavepath} starts with <ignoreprefix> (while creating '{svxid}.svx' )")
return False
if cavepath in self.caveslist: # primed with GCaveLookup
return self.caveslist[cavepath]
if cavepath.lower() in self.caveslist: # primed with GCaveLookup
return self.caveslist[cavepath.lower()]
rx_svxcollection = re.compile(r"(?i)caves-(\d\d\d\d)/(.*)$")
# rx_cave = re.compile(r"(?i)caves-(\d\d\d\d)/([-\d\w]+|\d\d\d\d-?\w+-\d+)")
@@ -1204,8 +1206,8 @@ class LoadingSurvex:
if cavepath[6:10] in ARGEAREAS:
return do_ARGE_cave(sluggy, caveid, area, svxid)
cave = create_new_cave(cavepath, f"Cave mentioned only in a survex file {svxid}") # uses the pending code to create pending cave descriptions
self.caveslist[cavepath] = cave
cave = create_new_cave(cavepath, svxid, f"Cave mentioned only in a survex file {svxid=}") # uses the pending code to create pending cave descriptions
self.caveslist[cavepath.lower()] = cave
message = f"\n ! MAKING cave {sluggy} for {cavepath=} {svxid=}"
# stash_data_issue(parser="survex", message=message, url="/survexfile/{svxid}.svx", sb=(svxid))
return cave
@@ -2439,13 +2441,14 @@ def MakeFileRoot(svxpath):
"""Returns a file_object.path
Used by the online survex file editor when re-parsing
or tries to find the primary survex file for this cave
Looks horrible, rewrite all this..
"""
cave = IdentifyCave(svxpath)
if not cave:
if svxpath != UNSEENS:
cave = create_new_cave(svxpath)
# is this really necessayr ?!
cave = create_new_cave(svxpath, "", "Make dummy Cave for MakeFileRoot {svxpath}")
# is this really necessary ?!
fileroot = SurvexFile(path=svxpath, cave=cave)
fileroot.save()
print(f" - Making/finding a new dummy root survexfile for this import: {svxpath} with cave {cave}")