mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-18 17:47:03 +00:00
stumbled on bug when no entries in logbook, fixed.
This commit is contained in:
@@ -57,14 +57,16 @@ class LogbookEntry(TroggleModel):
|
|||||||
|
|
||||||
<div class="trippeople">{% for personlogentry in logbook_entry.personlogentry_set.all %}{% if personlogentry.is_logbook_entry_author %}<u>{% if personlogentry.nickname_used %}{{personlogentry.nickname_used|safe}}{% else %}{{personlogentry.personexpedition.person|safe}}{% endif %}</u>,{% endif %}{% endfor %}{% for personlogentry in logbook_entry.personlogentry_set.all %}{% if personlogentry.is_logbook_entry_author %}{% else %}{% if personlogentry.nickname_used %}{{personlogentry.nickname_used|safe}}{% else %}{{personlogentry.personexpedition.person|safe}}{% endif %},{% endif %}{% endfor %}{% if logbook_entry.other_people %}, {{logbook_entry.other_people}}{% endif %}</div>
|
<div class="trippeople">{% for personlogentry in logbook_entry.personlogentry_set.all %}{% if personlogentry.is_logbook_entry_author %}<u>{% if personlogentry.nickname_used %}{{personlogentry.nickname_used|safe}}{% else %}{{personlogentry.personexpedition.person|safe}}{% endif %}</u>,{% endif %}{% endfor %}{% for personlogentry in logbook_entry.personlogentry_set.all %}{% if personlogentry.is_logbook_entry_author %}{% else %}{% if personlogentry.nickname_used %}{{personlogentry.nickname_used|safe}}{% else %}{{personlogentry.personexpedition.person|safe}}{% endif %},{% endif %}{% endfor %}{% if logbook_entry.other_people %}, {{logbook_entry.other_people}}{% endif %}</div>
|
||||||
'''
|
'''
|
||||||
author = (
|
if author := (
|
||||||
PersonLogEntry.objects.filter(logbook_entry=self, is_logbook_entry_author=True)
|
PersonLogEntry.objects.filter(logbook_entry=self, is_logbook_entry_author=True)
|
||||||
.first()
|
.first()
|
||||||
)
|
):
|
||||||
if author.nickname_used:
|
if author.nickname_used:
|
||||||
expoer = author.nickname_used
|
expoer = author.nickname_used
|
||||||
else:
|
else:
|
||||||
expoer = author.personexpedition.person.name()
|
expoer = author.personexpedition.person.name()
|
||||||
|
else:
|
||||||
|
expoer = "nobody"
|
||||||
names = f"<u>{expoer}</u>"
|
names = f"<u>{expoer}</u>"
|
||||||
|
|
||||||
participants = (
|
participants = (
|
||||||
@@ -119,7 +121,7 @@ def writelogbook(year, filename):
|
|||||||
t = loader.get_template("logbook2005style.html")
|
t = loader.get_template("logbook2005style.html")
|
||||||
logbookfile = t.render({"logbook_entries": logbook_entries})
|
logbookfile = t.render({"logbook_entries": logbook_entries})
|
||||||
except:
|
except:
|
||||||
print(" ! Very Bad Error RENDERING template " + template)
|
print(" ! Very Bad Error RENDERING template ", t)
|
||||||
raise
|
raise
|
||||||
# print(" - template rendered")
|
# print(" - template rendered")
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ LOGBOOK_PARSER_SETTINGS = {
|
|||||||
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
|
LOGBOOKS_DIR = "years" # subfolder of settings.EXPOWEB
|
||||||
|
|
||||||
ENTRIES = {
|
ENTRIES = {
|
||||||
|
"2029": 0,
|
||||||
|
"2028": 0,
|
||||||
|
"2027": 0,
|
||||||
|
"2026": 0,
|
||||||
|
"2025": 0,
|
||||||
"2024": 125,
|
"2024": 125,
|
||||||
"2023": 131,
|
"2023": 131,
|
||||||
"2022": 94,
|
"2022": 94,
|
||||||
@@ -379,8 +384,10 @@ def parser_html(year, expedition, txt, seq=""):
|
|||||||
dupl = {}
|
dupl = {}
|
||||||
|
|
||||||
# extract front material and stash for later use when rebuilding from list of entries
|
# extract front material and stash for later use when rebuilding from list of entries
|
||||||
headmatch = re.match(r"(?i)(?s).*<body[^>]*>(.*?)<hr.*", txt)
|
if headmatch := re.match(r"(?i)(?s).*<body[^>]*>(.*?)<hr.*", txt): # WALRUS OPERATOR
|
||||||
headpara = headmatch.groups()[0].strip()
|
headpara = headmatch.groups()[0].strip()
|
||||||
|
else:
|
||||||
|
headpara = ""
|
||||||
|
|
||||||
if len(headpara) > 0:
|
if len(headpara) > 0:
|
||||||
frontpath = Path(settings.EXPOWEB, LOGBOOKS_DIR, year, "frontmatter.html")
|
frontpath = Path(settings.EXPOWEB, LOGBOOKS_DIR, year, "frontmatter.html")
|
||||||
@@ -390,8 +397,10 @@ def parser_html(year, expedition, txt, seq=""):
|
|||||||
front.write(headpara + "\n")
|
front.write(headpara + "\n")
|
||||||
|
|
||||||
# extract END material and stash for later use when rebuilding from list of entries
|
# 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)
|
if endmatch := re.match(r"(?i)(?s).*<hr\s*/>([\s\S]*?)(?=</body)", txt): # WALRUS OPERATOR
|
||||||
endpara = endmatch.groups()[0].strip()
|
endpara = endmatch.groups()[0].strip()
|
||||||
|
else:
|
||||||
|
endpara = ""
|
||||||
|
|
||||||
if len(endpara) > 0:
|
if len(endpara) > 0:
|
||||||
print(f"\n - {year} endpara:\n'{endpara}'")
|
print(f"\n - {year} endpara:\n'{endpara}'")
|
||||||
@@ -399,7 +408,10 @@ def parser_html(year, expedition, txt, seq=""):
|
|||||||
with open(endpath, "w") as end:
|
with open(endpath, "w") as end:
|
||||||
end.write(endpara + "\n")
|
end.write(endpara + "\n")
|
||||||
|
|
||||||
tripparas = re.findall(r"<hr\s*/>([\s\S]*?)(?=<hr)", txt)
|
if tripparas := re.findall(r"<hr\s*/>([\s\S]*?)(?=<hr)", txt): # WALRUS OPERATOR
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
return None
|
||||||
logbook_entry_count = 0
|
logbook_entry_count = 0
|
||||||
for trippara in tripparas:
|
for trippara in tripparas:
|
||||||
logbook_entry_count += 1
|
logbook_entry_count += 1
|
||||||
@@ -656,6 +668,7 @@ def parse_logbook_for_expedition(expedition, blog=False):
|
|||||||
logentries = parser(year, expedition, txt, sq) # this launches the right parser
|
logentries = parser(year, expedition, txt, sq) # this launches the right parser
|
||||||
# --------------------
|
# --------------------
|
||||||
|
|
||||||
|
if logentries:
|
||||||
if len(logentries) == expect:
|
if len(logentries) == expect:
|
||||||
# print(f"OK {year} {len(logentries):5d} is {expect}\n")
|
# print(f"OK {year} {len(logentries):5d} is {expect}\n")
|
||||||
pass
|
pass
|
||||||
@@ -674,7 +687,7 @@ def LoadLogbook(year):
|
|||||||
clean_logbook_for_expedition(expo)
|
clean_logbook_for_expedition(expo)
|
||||||
logentries = []
|
logentries = []
|
||||||
|
|
||||||
logentries = parse_logbook_for_expedition(expo) # this actually loads the logbook for one expo
|
if logentries := parse_logbook_for_expedition(expo): # this actually loads the logbook for one expo # WALRUS
|
||||||
print(f" - Loaded logbook. {len(logentries)} entries." )
|
print(f" - Loaded logbook. {len(logentries)} entries." )
|
||||||
if year in BLOG_PARSER_SETTINGS:
|
if year in BLOG_PARSER_SETTINGS:
|
||||||
print(f" - Loading blog.." )
|
print(f" - Loading blog.." )
|
||||||
|
|||||||
Reference in New Issue
Block a user