2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

Trying to make kataster renumbering easier

This commit is contained in:
Philip Sargent 2024-06-08 13:30:39 +03:00
parent f156b89f32
commit 36ef9f961d

View File

@ -684,16 +684,21 @@ def read_cave(filename, cave=None):
def check_slug(areacode, kataster_number, unofficial_number, url):
if kataster_number:
if slug == f"{areacode}-{kataster_number}":
return
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}"
return slug
message = f" ! Cave Slug mismatch (kataster): '{slug}' != '{areacode}-{kataster_number}' {url=} in file {filename}. Adjusting.."
correctslug = f"{areacode}-{kataster_number}"
else:
if slug == f"{areacode}-{unofficial_number}":
return
message = f" ! Cave Slug mismatch (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}"
return slug
if slug.lower() == f"{areacode}-{unofficial_number.lower()}":
message = f" ! Cave Slug capitalisation incorrect (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}"
correctslug = slug.lower()
else:
message = f" ! Cave Slug mismatch (unofficial): '{slug}' != '{areacode}-{unofficial_number}' {url=} in file {filename}"
correctslug = slug # hack to stopit crashing
DataIssue.objects.create(parser="caves", message=message, url=f"{cave.slug}_cave_edit/")
print(message)
return correctslug
global entrances_xslug
global caves_xslug
@ -809,7 +814,8 @@ def read_cave(filename, cave=None):
cave.url = f"{cave.areacode}/{cave.number()}/{cave.number()}.html"
check_directory(cave.areacode, cave.number(), cave.url, cave)
check_slug(cave.areacode,cave.kataster_number, cave.unofficial_number, cave.url)
# This next line has no effect because the cave slug is not actually a field on the Cave object so we can't fix it here. to-do.
slug = check_slug(cave.areacode,cave.kataster_number, cave.unofficial_number, cave.url)
entrances = getXML(cavecontents, "entrance", context=context)
do_entrances()