summaryrefslogtreecommitdiffstats
path: root/parsers/survex.py
diff options
context:
space:
mode:
Diffstat (limited to 'parsers/survex.py')
-rw-r--r--parsers/survex.py51
1 files changed, 11 insertions, 40 deletions
diff --git a/parsers/survex.py b/parsers/survex.py
index fe7d211..88c1099 100644
--- a/parsers/survex.py
+++ b/parsers/survex.py
@@ -14,7 +14,7 @@ from troggle.core.models.survex import SurvexBlock, SurvexFile, SurvexPersonRole
from troggle.core.models.wallets import Wallet
from troggle.core.models.troggle import DataIssue, Expedition
from troggle.core.utils import chaosmonkey, get_process_memory
-from troggle.parsers.caves import create_new_cave
+from troggle.parsers.caves import create_new_cave, do_ARGE_cave
from troggle.parsers.people import GetPersonExpeditionNameLookup, known_foreigner
"""Imports the tree of survex files following from a defined root .svx file
@@ -1175,10 +1175,10 @@ class LoadingSurvex:
for key in self.caveslist:
cave = self.caveslist[key]
if type(cave) != Cave:
- print(f"BAD CAVE TYPE '{key}' -- {type(cave)}'{cave}'")
+ print(f"BAD CAVE TYPE '{type(cave)}'{cave}' -- {key}'")
for key in self.caveslist:
cave = self.caveslist[key]
- print(f"{key} -- Cave<{cave}>")
+ print(f"Cave<{cave}> -- {key}")
for i in self.ignoreprefix:
if cavepath.lower().startswith(i):
@@ -1192,19 +1192,23 @@ class LoadingSurvex:
# 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)
if path_match:
- sluggy = f"{path_match.group(1)}-{path_match.group(2)}"
+ area = path_match.group(1)
+ caveid = path_match.group(2)
+ sluggy = f"{area}-{caveid}"
seek = [sluggy, sluggy.replace("1623-","")] # to catch '2023-kt-02' etc
for s in seek:
if s in self.caveslist:
self.caveslist[cavepath] = self.caveslist[s] # set "caves-1626/107/107" as index to cave 1626-107
return self.caveslist[s]
+ if (cavepath.startswith("caves-1624") or cavepath.startswith("caves-1626")):
+ url = f"/survexfile/{svxid}.svx"
+ return do_ARGE_cave(sluggy, caveid, url, area, svxid)
+
cave = create_new_cave(cavepath, f"Make cave found in survex file {svxid}") # uses the pending code to create pending cave descriptions
self.caveslist[cavepath] = cave
- message = f"\n ! MAKING cave {sluggy} for {cavepath=} {svxid=} (not reporting this for 1624 or 1626)"
+ message = f"\n ! MAKING cave {sluggy} for {cavepath=} {svxid=}"
# stash_data_issue(parser="survex", message=message, url="/survexfile/{svxid}.svx", sb=(svxid))
- if not (cavepath.startswith("caves-1624") or cavepath.startswith("caves-1626")):
- print(message, file=sys.stderr)
return cave
else:
path_match = rx_svxcollection.search(svxid)
@@ -1219,39 +1223,6 @@ class LoadingSurvex:
print("\n" + message, file=sys.stderr)
stash_data_issue(parser="survex", message=message, url="{svxid}.svx", sb=(svxid))
return None
-
- def is_it_already_pending(self, headpath, includelabel, depth):
- """Ignore surface, kataser and gpx *include survex files"""
- if not self.pending:
- self.pending = set()
- fpending = Path(settings.CAVEDESCRIPTIONS, "pendingcaves.txt")
- if fpending.is_file():
- with open(fpending, "r") as fo:
- cids = fo.readlines()
- for cid in cids:
- id = cid.strip().rstrip("\n").upper()
- if cid.startswith("162"):
- self.pending.add(id)
- else:
- self.pending.add("1623-" + id)
-
- if headpath in self.ignorenoncave:
- message = f" - {headpath} is <ignorenoncave> (while creating '{includelabel}' sfile & sdirectory)"
- # print("\n"+message)
- # print("\n"+message,file=sys.stderr)
- return True
-
- caveid = f"{headpath[6:10]}-{headpath[11:]}".upper()
- if caveid in self.pending:
- # Yes we didn't find this cave, but we know it is a pending one. So not an error.
- print(f'! ALREADY PENDING caveid {caveid}',file=sys.stderr)
- return True
- id = caveid[5:]
- 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