summaryrefslogtreecommitdiffstats
path: root/parsers/logbooks.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2024-07-17 16:10:55 +0200
committerPhilip Sargent <philip.sargent@gmail.com>2024-07-17 16:10:55 +0200
commit6729698d7bb1a1eeb805f2c72561fb2a741e9b50 (patch)
tree371425b1280e4e7a4ea9e5866b9a6e4606835dd4 /parsers/logbooks.py
parent00f5ffa1b6b83dcdb0436f1f53e4516e15ed75e4 (diff)
downloadtroggle-6729698d7bb1a1eeb805f2c72561fb2a741e9b50.tar.gz
troggle-6729698d7bb1a1eeb805f2c72561fb2a741e9b50.tar.bz2
troggle-6729698d7bb1a1eeb805f2c72561fb2a741e9b50.zip
fix for non existent logbook between 1st Jan and start of expo
Diffstat (limited to 'parsers/logbooks.py')
-rw-r--r--parsers/logbooks.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/parsers/logbooks.py b/parsers/logbooks.py
index dabc701..b94f597 100644
--- a/parsers/logbooks.py
+++ b/parsers/logbooks.py
@@ -59,7 +59,7 @@ LOGBOOK_PARSER_SETTINGS = {
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
ENTRIES = {
- "2024": 20,
+ "2024": 27,
"2023": 86,
"2022": 94,
"2019": 55,
@@ -579,6 +579,8 @@ def parse_logbook_for_expedition(expedition, blog=False):
yearfile = DEFAULT_LOGBOOK_FILE
expedition.logbookfile = DEFAULT_LOGBOOK_FILE # don't change this if a blog
parsefunc = DEFAULT_LOGBOOK_PARSER
+
+ logbookpath = Path(yearfile)
if blog:
if year not in BLOG_PARSER_SETTINGS:
@@ -588,15 +590,16 @@ def parse_logbook_for_expedition(expedition, blog=False):
else:
yearfile, parsefunc = BLOG_PARSER_SETTINGS[year]
print(f" - BLOG file {yearfile} using parser {parsefunc}")
-
- logbookpath = Path(yearfile)
- # print(f" - Logbook file {yearfile} using parser {parsefunc}")
- # expedition.save()
+ else:
+ lb = Path(expologbase, year, logbookpath.stem + logbookpath.suffix)
+ if not (lb.is_file()):
+ message = f" ! Logbook file does not exist (yet): '{lb}'"
+ DataIssue.objects.create(parser="logbooks", message=message)
+ print(message)
for sq in ["", "2", "3", "4"]: # cope with blog saved as many separate files
lb = Path(expologbase, year, logbookpath.stem + sq + logbookpath.suffix)
if not (lb.is_file()):
- # print(f" ! End of blog. Next blog file in sequence not there:{lb}")
break
try:
with open(lb, "rb") as file_in:
@@ -706,8 +709,9 @@ def LoadLogbooks():
if year in ENTRIES:
loglist.append(expo)
else:
- print(" - No Logbook yet for: " + year) # catch case when preparing for next expo
-
+ print(" - No Logbook entries count yet for: " + year) # catch case when preparing for next expo
+ loglist.append(expo)
+
if year in BLOG_PARSER_SETTINGS:
bloglist.append(expo)