summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parsers/logbooks.py10
1 files 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).*<body[^>]*>(.*?)<hr.*", txt)
headpara = headmatch.groups()[0].strip()
- #print(f" - headpara:\n'{headpara}'")
if len(headpara) > 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).*<hr\s*/>([\s\S]*?)(?=</body)", txt)