mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
Pending caves with 1626 properly
This commit is contained in:
parent
25d5361da4
commit
476ee482fa
@ -8,7 +8,8 @@ from django.db import transaction
|
|||||||
|
|
||||||
from troggle.settings import SURVEX_DATA, EXPOWEB, CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
|
from troggle.settings import SURVEX_DATA, EXPOWEB, CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS
|
||||||
from troggle.core.models.troggle import DataIssue
|
from troggle.core.models.troggle import DataIssue
|
||||||
from troggle.core.models.caves import Area, Cave, Entrance, CaveSlug, EntranceSlug, CaveAndEntrance
|
from troggle.core.models.caves import Area, Cave, Entrance, CaveSlug, EntranceSlug, CaveAndEntrance, GetCaveLookup
|
||||||
|
|
||||||
'''Reads all the cave description data by parsing the xml files (stored as e.g. :EXPOWEB:/cave_data/1623-161.html )
|
'''Reads all the cave description data by parsing the xml files (stored as e.g. :EXPOWEB:/cave_data/1623-161.html )
|
||||||
and creating the various Cave, Entrance and necessary Area objects.
|
and creating the various Cave, Entrance and necessary Area objects.
|
||||||
|
|
||||||
@ -83,12 +84,10 @@ def set_dummy_entrance(id, slug, cave, msg="DUMMY"):
|
|||||||
DataIssue.objects.create(parser='caves', message=message, url=f'{cave.url}')
|
DataIssue.objects.create(parser='caves', message=message, url=f'{cave.url}')
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
def do_pending_cave(k, url, area_1623):
|
def do_pending_cave(k, url, area):
|
||||||
'''
|
'''
|
||||||
default for a PENDING cave, should be overwritten in the db later if a real cave of the same name exists
|
default for a PENDING cave, should be overwritten in the db later if a real cave of the same name exists
|
||||||
in expoweb/cave_data/1623-"k".html
|
in expoweb/cave_data/1623-"k".html
|
||||||
|
|
||||||
oops. Now need to do for 1626 area too
|
|
||||||
'''
|
'''
|
||||||
slug = k
|
slug = k
|
||||||
|
|
||||||
@ -116,14 +115,14 @@ def do_pending_cave(k, url, area_1623):
|
|||||||
cave = Cave(
|
cave = Cave(
|
||||||
unofficial_number = k,
|
unofficial_number = k,
|
||||||
underground_description = "Pending cave write-up - creating as empty object. No XML file available yet.",
|
underground_description = "Pending cave write-up - creating as empty object. No XML file available yet.",
|
||||||
survex_file = "caves-1623/" + k + "/" + k +".svx",
|
survex_file = f"caves-{area.short_name}/{k}/{k}.svx",
|
||||||
url = url,
|
url = url,
|
||||||
notes = default_note)
|
notes = default_note)
|
||||||
if cave:
|
if cave:
|
||||||
cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key.
|
cave.save() # must save to have id before foreign keys work. This is also a ManyToMany key.
|
||||||
cave.area.add(area_1623)
|
cave.area.add(area)
|
||||||
cave.save()
|
cave.save()
|
||||||
message = f" ! {k:12} {cave.underground_description}"
|
message = f" ! {k:14} {cave.underground_description} url: {url}"
|
||||||
DataIssue.objects.create(parser='caves', message=message, url=url)
|
DataIssue.objects.create(parser='caves', message=message, url=url)
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
@ -468,9 +467,9 @@ def readcaves():
|
|||||||
|
|
||||||
for k in pending:
|
for k in pending:
|
||||||
|
|
||||||
url = k.replace("-","/") # Note we are not appending the .htm as we are modern folks now.
|
|
||||||
area = area_1623
|
area = area_1623
|
||||||
areanum = k[0:3]
|
areanum = k[0:4]
|
||||||
|
url = areanum + "/" + k[5:] # Note we are not appending the .htm as we are modern folks now.
|
||||||
if areanum == "1623":
|
if areanum == "1623":
|
||||||
area = area_1623
|
area = area_1623
|
||||||
if areanum == "1624":
|
if areanum == "1624":
|
||||||
@ -478,7 +477,7 @@ def readcaves():
|
|||||||
if areanum == "1626":
|
if areanum == "1626":
|
||||||
area = area_1626
|
area = area_1626
|
||||||
try:
|
try:
|
||||||
do_pending_cave(k, url, area)
|
do_pending_cave(k[5:], url, area)
|
||||||
except:
|
except:
|
||||||
message = f" ! Error. Cannot create pending cave and entrance, pending-id:{k} in area {areanum}"
|
message = f" ! Error. Cannot create pending cave and entrance, pending-id:{k} in area {areanum}"
|
||||||
DataIssue.objects.create(parser='caves', message=message)
|
DataIssue.objects.create(parser='caves', message=message)
|
||||||
@ -500,3 +499,7 @@ def readcaves():
|
|||||||
for filename in next(os.walk(CAVEDESCRIPTIONS))[2]: #Should be a better way of getting a list of files
|
for filename in next(os.walk(CAVEDESCRIPTIONS))[2]: #Should be a better way of getting a list of files
|
||||||
if filename.endswith('.html'):
|
if filename.endswith('.html'):
|
||||||
readcave(filename)
|
readcave(filename)
|
||||||
|
|
||||||
|
print (" - Setting up all the variously useful alias names")
|
||||||
|
mycavelookup = GetCaveLookup()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user