From 13ffe1fcc60bf0f490d5cea57a75e3d00a2897f9 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Wed, 23 Mar 2022 23:35:42 +0000 Subject: [PATCH] url to full logbooks fixed in logbookentry --- parsers/logbooks.py | 12 ++++----- settings.py | 60 ++++++++++++++++++++++----------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 5ebc671..e91c69e 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -581,14 +581,14 @@ def LoadLogbookForExpedition(expedition, expect): cleanerrors(expedition.year) 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] parsefunc = yearlinks[expedition.year][1] 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 parsefunc = settings.DEFAULT_LOGBOOK_PARSER - cache_filename = Path(logbookfile + ".cache") + cache_filename = Path(str(logbookpath) + ".cache") if not cache_filename.is_file(): 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 try: 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") bad_cache= True if now - cache_t > 30*24*60*60: @@ -629,13 +629,13 @@ def LoadLogbookForExpedition(expedition, expect): except : print(" - Cache de-pickle failure \"" + str(cache_filename) +"\"") try: - file_in = open(logbookfile,'rb') + file_in = open(logbookpath,'rb') txt = file_in.read().decode("latin1") file_in.close() logbook_parseable = True except (IOError): logbook_parseable = False - print((" ! Couldn't open logbook " + logbookfile)) + print((" ! Couldn't open logbook " + logbookpath)) if logbook_parseable: parser = globals()[parsefunc] diff --git a/settings.py b/settings.py index fce69da..7c05550 100644 --- a/settings.py +++ b/settings.py @@ -75,36 +75,36 @@ DEFAULT_LOGBOOK_FILE = "logbook.html" # 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 LOGBOOK_PARSER_SETTINGS = { - "2010": ("2010/logbook.html", "Parseloghtmltxt"), - "2009": ("2009/2009logbook.txt", "Parselogwikitxt"), - "2008": ("2008/2008logbook.txt", "Parselogwikitxt"), - "2007": ("2007/logbook.html", "Parseloghtmltxt"), - "2006": ("2006/logbook.html", "Parseloghtmltxt"), -# "2006": ("2006/logbook/logbook_06.txt", "Parselogwikitxt"), - "2006": ("2006/logbook.html", "Parseloghtmltxt"), - "2005": ("2005/logbook.html", "Parseloghtmltxt"), - "2004": ("2004/logbook.html", "Parseloghtmltxt"), - "2003": ("2003/logbook.html", "Parseloghtml03"), - "2002": ("2002/logbook.html", "Parseloghtmltxt"), - "2001": ("2001/log.htm", "Parseloghtml01"), - "2000": ("2000/log.htm", "Parseloghtml01"), - "1999": ("1999/log.htm", "Parseloghtml01"), - "1998": ("1998/log.htm", "Parseloghtml01"), - "1997": ("1997/log.htm", "Parseloghtml01"), - "1996": ("1996/log.htm", "Parseloghtml01"), - "1995": ("1995/log.htm", "Parseloghtml01"), - "1994": ("1994/log.htm", "Parseloghtml01"), - "1993": ("1993/log.htm", "Parseloghtml01"), - "1992": ("1992/log.htm", "Parseloghtml01"), - "1991": ("1991/log.htm", "Parseloghtml01"), - "1990": ("1990/log.htm", "Parseloghtml01"), - "1989": ("1989/log.htm", "Parseloghtml01"), #crashes MySQL - "1988": ("1988/log.htm", "Parseloghtml01"), #crashes MySQL - "1987": ("1987/log.htm", "Parseloghtml01"), #crashes MySQL - "1985": ("1985/log.htm", "Parseloghtml01"), - "1984": ("1984/log.htm", "Parseloghtml01"), - "1983": ("1983/log.htm", "Parseloghtml01"), - "1982": ("1982/log.htm", "Parseloghtml01"), + "2010": ("logbook.html", "Parseloghtmltxt"), + "2009": ("2009logbook.txt", "Parselogwikitxt"), + "2008": ("2008logbook.txt", "Parselogwikitxt"), + "2007": ("logbook.html", "Parseloghtmltxt"), + "2006": ("logbook.html", "Parseloghtmltxt"), +# "2006": ("logbook/logbook_06.txt", "Parselogwikitxt"), + "2006": ("logbook.html", "Parseloghtmltxt"), + "2005": ("logbook.html", "Parseloghtmltxt"), + "2004": ("logbook.html", "Parseloghtmltxt"), + "2003": ("logbook.html", "Parseloghtml03"), + "2002": ("logbook.html", "Parseloghtmltxt"), + "2001": ("log.htm", "Parseloghtml01"), + "2000": ("log.htm", "Parseloghtml01"), + "1999": ("log.htm", "Parseloghtml01"), + "1998": ("log.htm", "Parseloghtml01"), + "1997": ("log.htm", "Parseloghtml01"), + "1996": ("log.htm", "Parseloghtml01"), + "1995": ("log.htm", "Parseloghtml01"), + "1994": ("log.htm", "Parseloghtml01"), + "1993": ("log.htm", "Parseloghtml01"), + "1992": ("log.htm", "Parseloghtml01"), + "1991": ("log.htm", "Parseloghtml01"), + "1990": ("log.htm", "Parseloghtml01"), + "1989": ("log.htm", "Parseloghtml01"), #crashes MySQL + "1988": ("log.htm", "Parseloghtml01"), #crashes MySQL + "1987": ("log.htm", "Parseloghtml01"), #crashes MySQL + "1985": ("log.htm", "Parseloghtml01"), + "1984": ("log.htm", "Parseloghtml01"), + "1983": ("log.htm", "Parseloghtml01"), + "1982": ("log.htm", "Parseloghtml01"), } # Caves for which survex files exist, but are not otherwise registered