2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-12-14 14:47:33 +00:00

attempt to simplify wnt horribly wrong

This commit is contained in:
Philip Sargent
2020-06-06 22:51:55 +01:00
parent f8a3c8f5bc
commit fda50ed570
9 changed files with 135 additions and 88 deletions

View File

@@ -292,7 +292,7 @@ def SetDatesFromLogbookEntries(expedition):
persontrip.save()
def LoadLogbookForExpedition(expedition):
def LoadLogbookForExpedition(expedition,numentries):
""" Parses all logbook entries for one expedition
"""
global logentries
@@ -358,8 +358,6 @@ def LoadLogbookForExpedition(expedition):
else:
print(" ! NO TRIP entries found in logbook, check the syntax.")
logentries=[] # flush for next year
if logbook_cached:
i=0
for entrytuple in range(len(logentries)):
@@ -368,19 +366,33 @@ def LoadLogbookForExpedition(expedition):
EnterLogIntoDbase(date, place, title, text, trippeople, expedition, logtime_underground,\
entry_type)
i +=1
return len(logentries)
def LoadLogbooks():
""" This is the master function for parsing all logbooks into the Troggle database.
"""
DataIssue.objects.filter(parser='logbooks').delete()
expos = Expedition.objects.all()
if len(expos) <= 1:
print(" ! No expeditions found. Load 'people' first.")
nologbook = ["1976", "1977","1978","1979","1980","1980","1981","1983","1984",
"1985","1986","1987","1988","1989","1990",]
for expo in expos:
if expo.year not in nologbook:
print((" - Logbook for: " + expo.year))
LoadLogbookForExpedition(expo)
entries = {"2020": 0, "2019": 40, "2018": 148, "2017": 120, "2016": 162, "2015": 158,
"2014": 130, "2013": 102, "2012": 150, "2011": 136, "2010": 44, "2009": 104,
"2008": 98, "2007": 222, "2006": 48, "2005": 110, "2004": 152, "2003": 80, "2002": 62,
"2001": 96, "2000": 108, "1999": 158, "1998": 86, "1997": 106, "1996": 188, "1995": 82,
"1994": 64, "1993": 82, "1992": 122, "1991": 76, "1982": 76}
try:
os.remove("loadlogbk.log")
except OSError:
pass
with open("loadlogbk.log", "a") as log:
for expo in expos:
if expo.year not in nologbook:
print((" - Logbook for: " + expo.year))
numentries = LoadLogbookForExpedition(expo, entries[expo.year])
log.write("{} {} should be {}\n".format(expo.year, numentries, entries[expo.year]))
dateRegex = re.compile(r'<span\s+class="date">(\d\d\d\d)-(\d\d)-(\d\d)</span>', re.S)