summaryrefslogtreecommitdiffstats
path: root/parsers
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@gmail.com>2023-10-22 21:28:38 +0300
committerPhilip Sargent <philip.sargent@gmail.com>2023-10-22 21:28:38 +0300
commit8f87e4f77a1128cb89826827bf5b9ae9dea901dc (patch)
treef361828e199603726cb61833bb62b4a06c3497c0 /parsers
parent1641dfe5f199e26607e8367395f4f8aa04eb376b (diff)
downloadtroggle-8f87e4f77a1128cb89826827bf5b9ae9dea901dc.tar.gz
troggle-8f87e4f77a1128cb89826827bf5b9ae9dea901dc.tar.bz2
troggle-8f87e4f77a1128cb89826827bf5b9ae9dea901dc.zip
bugfix - hack
Diffstat (limited to 'parsers')
-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)