mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 13:47:11 +00:00
EPOCH = 1970-01-01
This commit is contained in:
@@ -17,6 +17,7 @@ from troggle.core.models.logbooks import LogbookEntry, PersonLogEntry
|
||||
from troggle.core.models.troggle import DataIssue, Expedition
|
||||
from troggle.core.utils import get_process_memory, alphabet_suffix, unique_slug
|
||||
|
||||
EPOCH = settings.EPOCH
|
||||
"""
|
||||
Parses and imports logbooks in all their wonderful confusion
|
||||
See detailed explanation of the complete process:
|
||||
@@ -32,8 +33,6 @@ e.g. cave descriptions
|
||||
|
||||
- attach or link a DataIssue to an individual expo (logbook) so that it can be found and deleted
|
||||
|
||||
- replace explicit 1970 date with a constant EPOCH
|
||||
|
||||
- rewrite to use generators rather than storing everything intermediate in lists - to
|
||||
reduce memory impact [low priority]
|
||||
|
||||
@@ -260,8 +259,8 @@ def store_entry_into_database(date, place, tripcave, title, text, trippersons, a
|
||||
faster ?
|
||||
"""
|
||||
other_people = ", ".join(guests) # join list members separated by comma
|
||||
if guests:
|
||||
print(f" {date} - {guests}")
|
||||
# if guests:
|
||||
# print(f" {date} - {guests}")
|
||||
|
||||
nonLookupAttribs = {
|
||||
"place": place,
|
||||
@@ -291,7 +290,7 @@ 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..
|
||||
"""
|
||||
dummydate = date(1970, 1, 1) # replace with _EPOCH
|
||||
dummydate = EPOCH
|
||||
month = 1
|
||||
day = 1
|
||||
# message = f" ! - Trying to parse date in logbook: {tripdate} - {year}"
|
||||
@@ -315,7 +314,7 @@ def parser_date(tripdate, year):
|
||||
yadd = int(year[:2]) * 100
|
||||
day, month, year = int(mdategoof.group(1)), int(mdategoof.group(2)), int(mdategoof.group(4)) + yadd
|
||||
else:
|
||||
year = 1970 # replace with _EPOCH
|
||||
year = EPOCH.year
|
||||
message = f" ! - Bad date in logbook: {tripdate} - {year}"
|
||||
DataIssue.objects.create(parser="logbooks", message=message)
|
||||
|
||||
@@ -323,7 +322,7 @@ def parser_date(tripdate, year):
|
||||
except:
|
||||
message = f" ! - Failed to parse date in logbook: {tripdate} - {year}"
|
||||
DataIssue.objects.create(parser="logbooks", message=message)
|
||||
return datetime.date(1970, 1, 1) # replace with _EPOCH
|
||||
return EPOCH
|
||||
|
||||
|
||||
def parser_html(year, expedition, txt, seq=""):
|
||||
|
||||
Reference in New Issue
Block a user