summaryrefslogtreecommitdiffstats
path: root/parsers/caves.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-10-07 02:26:52 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-10-07 02:26:52 +0300
commit5f67af35f019e7054b9ce6de521b3fc96f5b0dc3 (patch)
treeb3ddad71a528cfb5ff07d8617e09bad4455d16c3 /parsers/caves.py
parentc3642f1ae434e8d1e5e7442670f936c4004bec98 (diff)
downloadtroggle-5f67af35f019e7054b9ce6de521b3fc96f5b0dc3.tar.gz
troggle-5f67af35f019e7054b9ce6de521b3fc96f5b0dc3.tar.bz2
troggle-5f67af35f019e7054b9ce6de521b3fc96f5b0dc3.zip
Better tag locations
Diffstat (limited to 'parsers/caves.py')
-rw-r--r--parsers/caves.py16
1 files changed, 12 insertions, 4 deletions
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