2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-22 07:11:52 +00:00

Fix odd glitches in cave parsing

This commit is contained in:
Philip Sargent 2023-09-28 01:01:32 +03:00
parent 7f9f598f11
commit e98c63f51c
4 changed files with 37 additions and 15 deletions

View File

@ -654,6 +654,9 @@ def GetCaveLookup():
("hc", "2018-dm-07"),
("loveshack", "1626-2018-ad-03"),
("crushed-garlic", "1626-2018-ad-03"),
("BuzzardHole", "1626-2023-buzzardhole"),
("2023-BuzzardHole", "1626-2023-buzzardhole"),
("1626-2023-BuzzardHole", "1626-2023-buzzardhole"),
]

View File

@ -161,6 +161,12 @@ def create_new_cave(svxpath, svxid=None, msg=None):
print(message)
return caves[0]
urltest = Cave.objects.filter(url=url)
if urltest:
message = f" ! Cave {urltest[0]} already exists with this url {url}. Can't create new cave {slug} from {svxpath} "
DataIssue.objects.create(parser="caves", message=message, url=url)
print(message)
return urltest[0]
try:
cave = do_pending_cave(k, caveid, url, areacode, msg)
except:
@ -191,7 +197,7 @@ def do_ARGE_cave(slug, caveid, areacode, svxid):
urltest = Cave.objects.filter(url=url)
if urltest:
message = f" ! Cave {urltest[0]} already exists with this url {url}. Can't create new ARGE cave {slug}"
message = f" ! Cave {urltest[0]} already exists with this url {url}. Can't create new ARGE cave {slug} from {svxid}"
DataIssue.objects.create(parser="caves", message=message, url=url)
print(message)
return urltest[0]
@ -725,10 +731,18 @@ def read_cave(filename, cave=None):
contextguess = f"/{slug[0:4]}/{slug}_cave_edit/" # guess as we havent read areacode yet
urltest = Cave.objects.filter(url=url)
if urltest:
message = f" ! - URL duplicate {urltest[0]} already exists with proposed url {url}. Should not create new cave {slug} from {filename}"
DataIssue.objects.create(parser="caves", message=message, url=contextguess)
print(message)
manual_edit = True
if not cave:
# we are parsing using databaseReset.py not an online edit
# we have already checked for uniqueness so we do not need the 'update' thinggy
manual_edit = False
try:
cave, state = Cave.objects.update_or_create(filename=filename) # replace with slug when CaveSlug tidied up
except:

View File

@ -47,8 +47,9 @@ ROOTBLOCK = "rootblock"
METRESINFEET = 3.28084
UNSEENS = "_unseens.svx"
IGNOREPREFIX = ["surface", "kataster", "fixedpts", "gpx", "deprecated", "dummy_"]
EXCEPTPREFIX = ["surface/terrain", "kataster/kataster-boundaries", "gpx/gpx_publish/essentials", "template", "docs", "deprecated", "subsections", "1623-and-1626-no-schoenberg-hs", "1623-and-1624-and-1626-and-1627", "1623-and-1626", "dummy_file"]
IGNOREFILES = ["dummy_file"]
IGNOREPREFIX = ["surface", "kataster", "fixedpts", "gpx", "deprecated"]
EXCEPTPREFIX = ["surface/terrain", "kataster/kataster-boundaries", "gpx/gpx_publish/essentials", "template", "docs", "deprecated", "subsections", "1623-and-1626-no-schoenberg-hs", "1623-and-1624-and-1626-and-1627", "1623-and-1626"]
# ignorenoncave = [
# "caves-1623",
# "caves-1623/2007-NEU",
@ -1185,9 +1186,12 @@ class LoadingSurvex:
cave = self.caveslist[key]
print(f"Cave<{cave}> -- {key}")
for f in IGNOREFILES:
if svxid.lower().startswith(f):
return False
for i in IGNOREPREFIX:
if cavepath.lower().startswith(i) or cavepath[11:].lower().startswith(i):
message = (f" - {cavepath} starts with <IGNOREPREFIX> (while creating '{svxid}.svx' )")
# message = (f" - {cavepath} is an <IGNOREPREFIX> (while looking at '{svxid}.svx' )")
# print(message, file=sys.stderr)
return False
@ -1200,30 +1204,31 @@ class LoadingSurvex:
if path_match:
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 . 3-digit searches only work for 1623 area
sluggy = f"{area}-{caveid}".lower() # GCaveLookup is all UPPER() and all lower() but not mixed
# if this comes from editing a survex file, we may already have loaded 3-digit aliases for 1623- from old wallets,
# so be careful here..
seek = {sluggy, sluggy.replace("1623-","")} # {} is a set
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[6:10] in ARGEAREAS:
#print(f"ARGE {area=} {caveid=} {cavepath} - {cavepath[11:]}", file=sys.stderr)
return do_ARGE_cave(sluggy, caveid, area, svxid)
cave = create_new_cave(cavepath, svxid, f"Cave mentioned only in a survex file {svxid=}") # uses the pending code to create pending cave descriptions
cave = create_new_cave(cavepath, svxid, f"Cave mentioned only in a survex file {svxid=}") # uses the pending code
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
else:
path_match = rx_svxcollection.search(svxid)
if path_match:
message = f" ! Recognised survex file which is not a cave at {svxid=}"
# message = f" ! Recognised survex file in area {path_match.group(1)} which is not a cave at {svxid=}"
# stash_data_issue(parser="survex", message=message, url=None, sb=(svxid))
# print(message, file=sys.stderr)
return False
else:
message = f" ! ERROR: no cave at '{svxid}.svx - is not a known cavename format. "
message = f" ! ERROR: no cave at '{svxid}.svx' {cavepath=} "
print("\n" + message)
print("\n" + message, file=sys.stderr)
stash_data_issue(parser="survex", message=message, url="{svxid}.svx", sb=(svxid))

View File

@ -23,7 +23,7 @@
{% endfor %}
</ul>
Red star <span style="color: red">*</span> against a name indicates that no survex file is explicitly associated with the cave.
<h3>1623</h3>
<div style="column-count: 3;">