diff --git a/parsers/caves.py b/parsers/caves.py index baea009..f1c8c4f 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -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()