mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-16 23:27:08 +00:00
deal with absent uneeded items
This commit is contained in:
@@ -712,14 +712,14 @@ def GetCaveLookup():
|
|||||||
("loveshack", "1626-2018-ad-03"),
|
("loveshack", "1626-2018-ad-03"),
|
||||||
("crushed-garlic", "1626-2018-ad-03"),
|
("crushed-garlic", "1626-2018-ad-03"),
|
||||||
|
|
||||||
# Renaming cave ids which end in a letter
|
# Renaming cave ids which end in a letter NB targets must be LOWER CASE
|
||||||
("2002-XX", "1623-2002-FB-01"),
|
("2002-XX", "1623-2002-fb-01"),
|
||||||
("2002-X09B", "1623-2002-XB09"),
|
("2002-X09B", "1623-2002-xb09"),
|
||||||
("2007-neu", "1623-2007-NEU-01"),
|
("2007-neu", "1623-2007-neu-01"),
|
||||||
("BuzzardHole", "1626-2023-BZ-01"),
|
("BuzzardHole", "1626-2023-Bbz-01"),
|
||||||
("2023-BuzzardHole", "1626-2023-BZ-01"),
|
("2023-BuzzardHole", "1626-2023-bz-01"),
|
||||||
("1626-2023-BuzzardHole", "1626-2023-BZ-01"),
|
("1626-2023-BuzzardHole", "1626-2023-bz-01"),
|
||||||
("1626-2023-buzzardhole","1626-2023-BZ-01"),
|
("1626-2023-buzzardhole","1626-2023-bz-01"),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -737,9 +737,15 @@ def GetCaveLookup():
|
|||||||
# Gcave_count[key] += 1
|
# Gcave_count[key] += 1
|
||||||
Gcavelookup[key] = Gcavelookup[alias]
|
Gcavelookup[key] = Gcavelookup[alias]
|
||||||
else:
|
else:
|
||||||
message = f" * Coding or cave existence mistake, cave for id '{alias}' does not exist. Expecting to set alias '{key}' to it"
|
if alias.lower() in Gcavelookup:
|
||||||
print(message)
|
Gcavelookup[key] = Gcavelookup[alias.lower()]
|
||||||
DataIssue.objects.update_or_create(parser="aliases", message=message)
|
message = f" - Warning, capitalisation error in alias list. cave for id '{alias}' does not exist but {alias.lower()} does."
|
||||||
|
print(message)
|
||||||
|
DataIssue.objects.update_or_create(parser="aliases", message=message)
|
||||||
|
else:
|
||||||
|
message = f" * Coding or cave existence mistake, cave for id '{alias}' does not exist. Expecting to set alias '{key}' to it"
|
||||||
|
print(message)
|
||||||
|
DataIssue.objects.update_or_create(parser="aliases", message=message)
|
||||||
|
|
||||||
addmore = {}
|
addmore = {}
|
||||||
for id in Gcavelookup:
|
for id in Gcavelookup:
|
||||||
|
|||||||
@@ -464,6 +464,9 @@ def read_entrance(filename, ent=None):
|
|||||||
Returns:
|
Returns:
|
||||||
The entrance object, or a new entrance object if `ent` is None.
|
The entrance object, or a new entrance object if `ent` is None.
|
||||||
"""
|
"""
|
||||||
|
def getXMLmin0(field):
|
||||||
|
return getXML(entrancecontents, field, minItems=0, maxItems=1, context=context)
|
||||||
|
|
||||||
def getXMLmax1(field):
|
def getXMLmax1(field):
|
||||||
return getXML(entrancecontents, field, maxItems=1, context=context)
|
return getXML(entrancecontents, field, maxItems=1, context=context)
|
||||||
|
|
||||||
@@ -508,7 +511,7 @@ def read_entrance(filename, ent=None):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
entrancecontents = entrancecontentslist[0]
|
entrancecontents = entrancecontentslist[0]
|
||||||
slugs = getXML(entrancecontents, "slug", context=context)
|
slugs = getXMLmin0("slug")
|
||||||
# we ignore all these, because we now just use the filename. But if they are there, we validate them.
|
# we ignore all these, because we now just use the filename. But if they are there, we validate them.
|
||||||
if len(slugs) > 0 :
|
if len(slugs) > 0 :
|
||||||
slug = slugs[0]
|
slug = slugs[0]
|
||||||
@@ -519,8 +522,8 @@ def read_entrance(filename, ent=None):
|
|||||||
DataIssue.objects.create(parser="entrances", message=message, url=cave_edit_url)
|
DataIssue.objects.create(parser="entrances", message=message, url=cave_edit_url)
|
||||||
print(message)
|
print(message)
|
||||||
|
|
||||||
if slug != entslug_fn:
|
if slug and slug != entslug_fn:
|
||||||
message = f" ! - Warning, mismatch between entrance slug and filename: {slug=} {filename=}. Ignoring slug field, using filename."
|
message = f" ! - Warning, mismatch between entrance slug (or unofficial name) and filename: {slug=} {filename=}. Ignoring slug field, using filename."
|
||||||
DataIssue.objects.create(parser="xEntrances", message=message, url=cave_edit_url)
|
DataIssue.objects.create(parser="xEntrances", message=message, url=cave_edit_url)
|
||||||
print(message)
|
print(message)
|
||||||
slug = entslug_fn # force
|
slug = entslug_fn # force
|
||||||
@@ -604,8 +607,11 @@ def read_cave(filename, mvf=None, cave=None):
|
|||||||
elements = xml_root.findall(t)
|
elements = xml_root.findall(t)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
def getXMLmin0(field):
|
||||||
|
return getXML(cavecontents, field, minItems=0, maxItems=1, context=context)
|
||||||
|
|
||||||
def getXMLmax1(field):
|
def getXMLmax1(field):
|
||||||
return getXML(cavecontents, field, maxItems=1, context=context)
|
return getXML(cavecontents, field, minItems=0, maxItems=1, context=context)
|
||||||
|
|
||||||
def do_entrances():
|
def do_entrances():
|
||||||
"""For both bulk import and individual re-reading of cave_data file,
|
"""For both bulk import and individual re-reading of cave_data file,
|
||||||
@@ -813,11 +819,13 @@ def read_cave(filename, mvf=None, cave=None):
|
|||||||
#kataster_status = getXMLmax1("kataster_status")
|
#kataster_status = getXMLmax1("kataster_status")
|
||||||
#underground_centre_line = getXMLmax1("underground_centre_line")
|
#underground_centre_line = getXMLmax1("underground_centre_line")
|
||||||
notes = getXMLmax1("notes")
|
notes = getXMLmax1("notes")
|
||||||
length = getXMLmax1("length")
|
|
||||||
depth = getXMLmax1("depth")
|
|
||||||
extent = getXMLmax1("extent")
|
|
||||||
survex_file = getXMLmax1("survex_file")
|
survex_file = getXMLmax1("survex_file")
|
||||||
description_file = getXMLmax1("description_file")
|
description_file = getXMLmax1("description_file")
|
||||||
|
|
||||||
|
length = getXMLmin0("length")
|
||||||
|
depth = getXMLmin0("depth")
|
||||||
|
extent = getXMLmin0("extent")
|
||||||
|
|
||||||
areacode = slug[:4]
|
areacode = slug[:4]
|
||||||
|
|
||||||
contextguess = f"/{slug[0:4]}/{slug}_cave_edit/"
|
contextguess = f"/{slug[0:4]}/{slug}_cave_edit/"
|
||||||
@@ -870,9 +878,12 @@ def read_cave(filename, mvf=None, cave=None):
|
|||||||
#cave.kataster_status=kataster_status[0]
|
#cave.kataster_status=kataster_status[0]
|
||||||
#cave.underground_centre_line=underground_centre_line[0]
|
#cave.underground_centre_line=underground_centre_line[0]
|
||||||
cave.notes=notes[0]
|
cave.notes=notes[0]
|
||||||
cave.length=length[0]
|
if length:
|
||||||
cave.depth=depth[0]
|
cave.length=length[0]
|
||||||
cave.extent=extent[0]
|
if depth:
|
||||||
|
cave.depth=depth[0]
|
||||||
|
if extent:
|
||||||
|
cave.extent=extent[0]
|
||||||
cave.survex_file=survex_file[0]
|
cave.survex_file=survex_file[0]
|
||||||
cave.description_file=description_file[0]
|
cave.description_file=description_file[0]
|
||||||
# cave.url=url[0] # set algorithically:
|
# cave.url=url[0] # set algorithically:
|
||||||
|
|||||||
Reference in New Issue
Block a user