diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 63533f3..54f4f56 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -252,8 +252,12 @@ def tidy_trip_image_urls(text, date): # print(f"tidy_trip_image_urls() - {y}\n {line}") return text -def tidy_tid(tid, title): - +def tidy_tid(tid, title, date): + if not tid.startswith(date): + message = f" ! - Logentry id does not have the same date {date=} {tid=} " + DataIssue.objects.create(parser="logbooks", message=message) + print(message) + if tid is not None: return tid @@ -421,7 +425,7 @@ def parser_html(year, expedition, txt, seq=""): print(msg) DataIssue.objects.create(parser="logbooks", message=msg) continue - + lgdate = f"{ldate}"[:10] # Now we have a date, we can reset tripid tid = reset_trip_id(ldate) @@ -448,7 +452,7 @@ def parser_html(year, expedition, txt, seq=""): trippersons, author, guests = tidy_trip_persons(trippeople, triptitle, expedition, tu, tid) tripcave = tidy_trip_cave(place) tripcontent = tidy_trip_image_urls(tripcontent, ldate) - tid = tidy_tid(tid, triptitle) + tid = tidy_tid(tid, triptitle, lgdate) entrytuple = (ldate, place, tripcave, triptitle, tripcontent, trippersons, author, guests, expedition, tu, tid) logentries.append(entrytuple) @@ -555,7 +559,7 @@ def parser_blog(year, expedition, txt, sq=""): # print(f" - author: {author}") tripcave = tidy_trip_cave(place) tripcontent = tidy_trip_image_urls(tripcontent, year) - tid = tidy_tid(tid, triptitle) + tid = tidy_tid(tid, triptitle, datestamp) entrytuple = (tripdate, place, tripcave, triptitle, tripcontent, trippersons, author, guests, expedition, tu, tid) logentries.append(entrytuple)