2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-16 07:07:13 +00:00

belt and braces prevent bad lbe ids

This commit is contained in:
2024-07-23 11:34:12 +02:00
parent feaf38aa39
commit 07fc372b41
3 changed files with 18 additions and 4 deletions

View File

@@ -59,8 +59,8 @@ LOGBOOK_PARSER_SETTINGS = {
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
ENTRIES = {
"2024": 27,
"2023": 86,
"2024": 41,
"2023": 91,
"2022": 94,
"2019": 55,
"2018": 95,
@@ -299,6 +299,11 @@ def store_entry_into_database(date, place, tripcave, title, text, trippersons, a
def parser_date(tripdate, year):
"""Interprets dates in the expo logbooks and returns a correct datetime.date object
Does NOT actually check that it is a truly valid date..
tripdate : string
year : string
Nasty bug if it returns just the year which leads to a logbook id '/2023' instead of '/2023-07-16b'
"""
dummydate = EPOCH
month = 1
@@ -410,6 +415,13 @@ def parser_html(year, expedition, txt, seq=""):
continue
ldate = parser_date(tripdate.strip(), year)
if len(str(ldate)) < 10:
ldate = date(year, 10, 1) # 1st October
msg = f" !- Logbook. Bad parsed date '{tripdate}' setting to '{ldate}'"
print(msg)
DataIssue.objects.create(parser="logbooks", message=msg)
continue
# Now we have a date, we can reset tripid
tid = reset_trip_id(ldate)