From 8f87e4f77a1128cb89826827bf5b9ae9dea901dc Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 22 Oct 2023 21:28:38 +0300 Subject: [PATCH] bugfix - hack --- parsers/logbooks.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 33b8838..3789b4a 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -340,7 +340,8 @@ def parser_html(year, expedition, txt, seq=""): \s whitespace \S NOT whitespace - You can't see it here, but a round-trip export-then-import will move + You can't see it here, but a round-trip export-then-import + for a new year logbook will move the endmatter up to the frontmatter. This made sense when translating from parser_html_01 format logfiles, believe me. """ @@ -351,11 +352,12 @@ def parser_html(year, expedition, txt, seq=""): headmatch = re.match(r"(?i)(?s).*]*>(.*?) 0: frontpath = Path(settings.EXPOWEB, LOGBOOKS_DIR, year, "frontmatter.html") - with open(frontpath, "w") as front: - front.write(headpara + "\n") + if not frontpath.is_file: + # dont attempt to rewrite it. So this will only run once, for new logbook. Buggy otherwise. + with open(frontpath, "w") as front: + front.write(headpara + "\n") # extract END material and stash for later use when rebuilding from list of entries endmatch = re.match(r"(?i)(?s).*([\s\S]*?)(?=