url to full logbooks fixed in logbookentry

This commit is contained in:
Philip Sargent 2022-03-23 23:35:42 +00:00
parent 9ccf5912d4
commit 13ffe1fcc6
2 changed files with 36 additions and 36 deletions

View File

@ -581,14 +581,14 @@ def LoadLogbookForExpedition(expedition, expect):
cleanerrors(expedition.year) cleanerrors(expedition.year)
if expedition.year in yearlinks: if expedition.year in yearlinks:
logbookfile = os.path.join(expologbase, yearlinks[expedition.year][0]) logbookpath = Path(expologbase) / expedition.year / yearlinks[expedition.year][0]
expedition.logbookfile = yearlinks[expedition.year][0] expedition.logbookfile = yearlinks[expedition.year][0]
parsefunc = yearlinks[expedition.year][1] parsefunc = yearlinks[expedition.year][1]
else: else:
logbookfile = os.path.join(expologbase, expedition.year, settings.DEFAULT_LOGBOOK_FILE) logbookpath = os.path.join(expologbase, expedition.year, settings.DEFAULT_LOGBOOK_FILE)
expedition.logbookfile = settings.DEFAULT_LOGBOOK_FILE expedition.logbookfile = settings.DEFAULT_LOGBOOK_FILE
parsefunc = settings.DEFAULT_LOGBOOK_PARSER parsefunc = settings.DEFAULT_LOGBOOK_PARSER
cache_filename = Path(logbookfile + ".cache") cache_filename = Path(str(logbookpath) + ".cache")
if not cache_filename.is_file(): if not cache_filename.is_file():
print(" - Cache file does not exist \"" + str(cache_filename) +"\"") print(" - Cache file does not exist \"" + str(cache_filename) +"\"")
@ -599,7 +599,7 @@ def LoadLogbookForExpedition(expedition, expect):
bad_cache = False # temporarily disable reading the cache - buggy bad_cache = False # temporarily disable reading the cache - buggy
try: try:
cache_t = os.path.getmtime(cache_filename) cache_t = os.path.getmtime(cache_filename)
if os.path.getmtime(logbookfile) - cache_t > 2: # at least 2 secs later if os.path.getmtime(logbookpath) - cache_t > 2: # at least 2 secs later
print(" - ! Cache is older than the logbook file") print(" - ! Cache is older than the logbook file")
bad_cache= True bad_cache= True
if now - cache_t > 30*24*60*60: if now - cache_t > 30*24*60*60:
@ -629,13 +629,13 @@ def LoadLogbookForExpedition(expedition, expect):
except : except :
print(" - Cache de-pickle failure \"" + str(cache_filename) +"\"") print(" - Cache de-pickle failure \"" + str(cache_filename) +"\"")
try: try:
file_in = open(logbookfile,'rb') file_in = open(logbookpath,'rb')
txt = file_in.read().decode("latin1") txt = file_in.read().decode("latin1")
file_in.close() file_in.close()
logbook_parseable = True logbook_parseable = True
except (IOError): except (IOError):
logbook_parseable = False logbook_parseable = False
print((" ! Couldn't open logbook " + logbookfile)) print((" ! Couldn't open logbook " + logbookpath))
if logbook_parseable: if logbook_parseable:
parser = globals()[parsefunc] parser = globals()[parsefunc]

View File

@ -75,36 +75,36 @@ DEFAULT_LOGBOOK_FILE = "logbook.html"
# All years since 2010 use the default value for Logbook parser # All years since 2010 use the default value for Logbook parser
# but several don't work, and are skipped by the parsing code, e.g. 1983 # but several don't work, and are skipped by the parsing code, e.g. 1983
LOGBOOK_PARSER_SETTINGS = { LOGBOOK_PARSER_SETTINGS = {
"2010": ("2010/logbook.html", "Parseloghtmltxt"), "2010": ("logbook.html", "Parseloghtmltxt"),
"2009": ("2009/2009logbook.txt", "Parselogwikitxt"), "2009": ("2009logbook.txt", "Parselogwikitxt"),
"2008": ("2008/2008logbook.txt", "Parselogwikitxt"), "2008": ("2008logbook.txt", "Parselogwikitxt"),
"2007": ("2007/logbook.html", "Parseloghtmltxt"), "2007": ("logbook.html", "Parseloghtmltxt"),
"2006": ("2006/logbook.html", "Parseloghtmltxt"), "2006": ("logbook.html", "Parseloghtmltxt"),
# "2006": ("2006/logbook/logbook_06.txt", "Parselogwikitxt"), # "2006": ("logbook/logbook_06.txt", "Parselogwikitxt"),
"2006": ("2006/logbook.html", "Parseloghtmltxt"), "2006": ("logbook.html", "Parseloghtmltxt"),
"2005": ("2005/logbook.html", "Parseloghtmltxt"), "2005": ("logbook.html", "Parseloghtmltxt"),
"2004": ("2004/logbook.html", "Parseloghtmltxt"), "2004": ("logbook.html", "Parseloghtmltxt"),
"2003": ("2003/logbook.html", "Parseloghtml03"), "2003": ("logbook.html", "Parseloghtml03"),
"2002": ("2002/logbook.html", "Parseloghtmltxt"), "2002": ("logbook.html", "Parseloghtmltxt"),
"2001": ("2001/log.htm", "Parseloghtml01"), "2001": ("log.htm", "Parseloghtml01"),
"2000": ("2000/log.htm", "Parseloghtml01"), "2000": ("log.htm", "Parseloghtml01"),
"1999": ("1999/log.htm", "Parseloghtml01"), "1999": ("log.htm", "Parseloghtml01"),
"1998": ("1998/log.htm", "Parseloghtml01"), "1998": ("log.htm", "Parseloghtml01"),
"1997": ("1997/log.htm", "Parseloghtml01"), "1997": ("log.htm", "Parseloghtml01"),
"1996": ("1996/log.htm", "Parseloghtml01"), "1996": ("log.htm", "Parseloghtml01"),
"1995": ("1995/log.htm", "Parseloghtml01"), "1995": ("log.htm", "Parseloghtml01"),
"1994": ("1994/log.htm", "Parseloghtml01"), "1994": ("log.htm", "Parseloghtml01"),
"1993": ("1993/log.htm", "Parseloghtml01"), "1993": ("log.htm", "Parseloghtml01"),
"1992": ("1992/log.htm", "Parseloghtml01"), "1992": ("log.htm", "Parseloghtml01"),
"1991": ("1991/log.htm", "Parseloghtml01"), "1991": ("log.htm", "Parseloghtml01"),
"1990": ("1990/log.htm", "Parseloghtml01"), "1990": ("log.htm", "Parseloghtml01"),
"1989": ("1989/log.htm", "Parseloghtml01"), #crashes MySQL "1989": ("log.htm", "Parseloghtml01"), #crashes MySQL
"1988": ("1988/log.htm", "Parseloghtml01"), #crashes MySQL "1988": ("log.htm", "Parseloghtml01"), #crashes MySQL
"1987": ("1987/log.htm", "Parseloghtml01"), #crashes MySQL "1987": ("log.htm", "Parseloghtml01"), #crashes MySQL
"1985": ("1985/log.htm", "Parseloghtml01"), "1985": ("log.htm", "Parseloghtml01"),
"1984": ("1984/log.htm", "Parseloghtml01"), "1984": ("log.htm", "Parseloghtml01"),
"1983": ("1983/log.htm", "Parseloghtml01"), "1983": ("log.htm", "Parseloghtml01"),
"1982": ("1982/log.htm", "Parseloghtml01"), "1982": ("log.htm", "Parseloghtml01"),
} }
# Caves for which survex files exist, but are not otherwise registered # Caves for which survex files exist, but are not otherwise registered