summaryrefslogtreecommitdiffstats
path: root/parsers/caves.py
diff options
context:
space:
mode:
Diffstat (limited to 'parsers/caves.py')
-rw-r--r--parsers/caves.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/parsers/caves.py b/parsers/caves.py
index bc2bfbc..9d95f32 100644
--- a/parsers/caves.py
+++ b/parsers/caves.py
@@ -84,6 +84,15 @@ def do_pending_cave(k, url, area):
in expoweb/cave_data/1623-"k".html
'''
slug = k
+
+ g = GetCaveLookup()
+ if slug in g:
+ message = f" ! {k} cave listed in pendingcaves.txt already exists."
+ DataIssue.objects.create(parser='caves', message=message, url=url)
+ print(message)
+ return
+
+
default_note = f"_Survex file found in loser repo but no description in expoweb <br><br><br>\n"
default_note += f"INSTRUCTIONS: First open 'This survex file' (link above the CaveView panel) to find the date and info. Then "
@@ -111,7 +120,7 @@ def do_pending_cave(k, url, area):
cave = Cave(
unofficial_number = k,
underground_description = "Pending cave write-up - creating as empty object. No XML file available yet.",
- survex_file = f"caves-{area.short_name}/{k}/{k}.svx",
+ survex_file = f"caves-{area.short_name}/{k[5:]}/{k[5:]}.svx",
url = url,
notes = default_note)
if cave:
@@ -458,27 +467,6 @@ def readcaves():
print(" - Saving Area 1626")
area_1626.save()
- print (" - Setting pending caves")
- # Do this first, so that these empty entries are overwritten as they get properly created.
-
- for k in pending:
-
- area = area_1623
- areanum = k[0:4]
- url = areanum + "/" + k[5:] # Note we are not appending the .htm as we are modern folks now.
- if areanum == "1623":
- area = area_1623
- if areanum == "1624":
- area = area_1624
- if areanum == "1626":
- area = area_1626
- try:
- do_pending_cave(k[5:], url, area)
- except:
- message = f" ! Error. Cannot create pending cave and entrance, pending-id:{k} in area {areanum}"
- DataIssue.objects.create(parser='caves', message=message)
- print(message)
- raise
with transaction.atomic():
print(" - settings.CAVEDESCRIPTIONS: ", CAVEDESCRIPTIONS)
@@ -498,4 +486,27 @@ def readcaves():
print (" - Setting up all the variously useful alias names")
mycavelookup = GetCaveLookup()
+
+ print (" - Setting pending caves")
+ # Do this last, so we can detect if they are created and no longer 'pending'
+
+ for k in pending:
+
+ area = area_1623
+ areanum = k[0:4]
+ url = areanum + "/" + k[5:] # Note we are not appending the .htm as we are modern folks now.
+ if areanum == "1623":
+ area = area_1623
+ if areanum == "1624":
+ area = area_1624
+ if areanum == "1626":
+ area = area_1626
+ try:
+ do_pending_cave(k, url, area)
+ except:
+ message = f" ! Error. Cannot create pending cave and entrance, pending-id:{k} in area {areanum}"
+ DataIssue.objects.create(parser='caves', message=message)
+ print(message)
+ raise
+