From 5f67af35f019e7054b9ce6de521b3fc96f5b0dc3 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 7 Oct 2023 02:26:52 +0300 Subject: Better tag locations --- parsers/caves.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'parsers/caves.py') diff --git a/parsers/caves.py b/parsers/caves.py index cc9d22d..91985d1 100644 --- a/parsers/caves.py +++ b/parsers/caves.py @@ -10,6 +10,7 @@ from django.db import transaction from troggle.core.models.caves import Cave, CaveAndEntrance, Entrance, GetCaveLookup from troggle.core.models.logbooks import CaveSlug +from troggle.core.models.survex import SurvexStation from troggle.core.models.troggle import DataIssue from troggle.settings import CAVEDESCRIPTIONS, ENTRANCEDESCRIPTIONS, EXPOWEB, SURVEX_DATA @@ -424,15 +425,22 @@ def boolify(boolstrs): def validate_station(station): """It is possible to break troggle entirely by getting this wrong. - These station identifiers are matched against other statsions using .endswith() + These station identifiers are matched against other stations using .endswith() in parsers/locations.py so a simple number here will match hundreds of SUrvexStation objects It should be, e.g. "1623.p240" + + We will test them against survex stations after we have loaded them. """ if station == "": return True + + # CANNOT test against locations as we have not read the survex files yet. Hmph. + + # Must have the right format in its name dot = station.find(".") if dot == -1: + print(dot) # no full stop found. Bad station identifier. raise else: @@ -540,6 +548,7 @@ def read_entrance(filename, ent=None): ent.url=url[0] for st in [ent.exact_station, ent.other_station, ent.tag_station]: + #validate_station(st) try: validate_station(st) except: @@ -547,9 +556,6 @@ def read_entrance(filename, ent=None): #http://localhost:8000/1623/2023-EBH-01/1623-2023-EBH-01:1623-2023-EBH-01_entrance_edit DataIssue.objects.create(parser="entrances", message=message, url=f"/1623/{slug}/{slug}:{slug}_entrance_edit") print(message) - # ent_issues = DataIssue.objects.filter(parser="entrances") - # print(f".. We now have {len(ent_issues)} entrance DataIssues") - return None ent.save() return ent @@ -811,6 +817,8 @@ def read_cave(filename, cave=None): message = f' ! {slug:12} survex filename does not exist :LOSER:"{survex_file[0]}" in "{filename}"' DataIssue.objects.create(parser="caves", message=message, url=f"/{slug[0:4]}/{slug}_cave_edit/") print(message) + # else: + # print(f"{slug:12} survex filename UNSET") if description_file[0]: # if not an empty string -- cgit v1.2.3