sorted by surname alphabetically

This commit is contained in:
2025-06-28 15:14:00 +03:00
parent 98f57558ec
commit 8e5d8440ac
3 changed files with 986 additions and 37 deletions

View File

@@ -3,7 +3,7 @@ import sys, string, re, os
from datetime import date
# run within the /folk/ folder:
# python3 ../scripts/make-folklist.py <folk.csv >index.htm
# python3 ../scripts/make-folklist.py <folk.csv >index.html
# re-run it every time you edit the folk.csv file to add someone you have forgotten
# it needs to be run on the server too as the file produced is ignored by git
@@ -14,7 +14,8 @@ headcount = 0
pics = 0
allyears = 0
recordholders = []
output = ""
output = {}
surnames = {}
n = 0
lines = sys.stdin.readlines()
@@ -42,6 +43,7 @@ def troggle_slugify(longname):
if slug in slug_cache:
slug_cache[slug] += 1
slug = f"{slug}_{slug_cache[slug]}"
sys.stderr.write(f"Slug uniqueness enforced: {slug}\n")
slug_cache[slug] = 1
# t = longname.find("&")
@@ -62,6 +64,10 @@ for r in lines[1:]:
except:
print(f'Exception in line {n}: {r}')
namevis = name.replace('""', '"').strip('"')
nameurl = troggle_slugify(namevis) # unique
output[nameurl] = ""
expos_caving = len([t for t in years if t == "1"])
expos_notcaving = len([t for t in years if t == "-1"])
if(expos_caving == 0 and expos_notcaving == 0):
@@ -72,34 +78,24 @@ for r in lines[1:]:
bierbook[name] = True
if(expos_caving and name != 'Rover Richardson' and name != 'Bier Tent'): headcount += 1
if mug: pics +=1
output += '<tr><td>'
if expos_caving == 0: output += '<span class="didntcave">'
output[nameurl] += '<tr><td>'
if expos_caving == 0: output[nameurl] += '<span class="didntcave">'
# Need to manage names e.g. <span lang=""sv"">Leif Hornsved (Nickname)</span> => LeifHornsved
namevis = name.replace('""', '"').strip('"')
# Need to manage e.g.Olaf K&auml;hler
# Need to manage e.g. Bal%26aacute%3BzsIzapy
# nameurl = namevis.replace(' ', '')
# nameurl = nameurl.replace('&', '%26')
# nameurl = nameurl.replace(';', '%3B')
# new url using slug
nameurl = troggle_slugify(namevis)
namelink= "<a href='/person/" + nameurl + "'>" + namevis + "</a>"
output += namelink
#output += name.replace('""', '"')
output[nameurl] += namelink
#output[nameurl] += name.replace('""', '"')
if expos_caving == 0: output += '</span>'
output += '</td><td>'
if guest: output += '&sect;'
output += '</td><td>'
if vfho: output += '&curren;'
output += '</td><td>'
if expos_caving == 0: output[nameurl] += '</span>'
output[nameurl] += '</td><td>'
if guest: output[nameurl] += '&sect;'
output[nameurl] += '</td><td>'
if vfho: output[nameurl] += '&curren;'
output[nameurl] += '</td><td>'
if mug:
if not (os.path.isfile(mug)):
print("ERROR: --------------- mug file does not exist: ", mug, file=sys.stderr)
if mug: output += f'<a href={mug}><img alt=":-)" src="i/mug.png" /></a>'
output += '</td>'
if mug: output[nameurl] += f'<a href={mug}><img alt=":-)" src="i/mug.png" /></a>'
output[nameurl] += '</td>'
for y in range(len(years)):
if(years[y]):
m = str(76 + y)[-2:]
@@ -111,21 +107,24 @@ for r in lines[1:]:
except IndexError:
sys.stderr.write(repr(r) +":::"+ str(y) + "\n")
raise
output += '<td class="nonempty">' + m + '</td>'
output[nameurl] += '<td class="nonempty">' + m + '</td>'
else:
output += '<td></td>'
output[nameurl] += '<td></td>'
# print number of expos, non-caving in red. Only print numbers > 0
output += '<td style="text-align: right; width:36px; font-size:85%">'
output[nameurl] += '<td style="text-align: right; width:36px; font-size:85%">'
if(expos_notcaving):
if(expos_caving):
output += '%d+<span class="didntcave">%d</span>' % (expos_caving, expos_notcaving)
output[nameurl] += '%d+<span class="didntcave">%d</span>' % (expos_caving, expos_notcaving)
else:
output += '<span class="didntcave">%d</span>' % expos_notcaving
output[nameurl] += '<span class="didntcave">%d</span>' % expos_notcaving
else:
output += '%d' % expos_caving
output += '</td></tr>\n'
output[nameurl] += '%d' % expos_caving
output[nameurl] += '</td></tr>\n'
recordholders.append((expos_caving, name))
def get_surname(key):
parts = key.split("-")
return parts[1] if len(parts) == 2 else parts[0] # Use whole key if no dash
def collapse(m):
@@ -133,7 +132,7 @@ def collapse(m):
if(n == 1): return m.group()
else: return '<td colspan="%d"></td>' % n
#output = re.sub(r'(<td></td>)+',collapse, output)
#output[nameurl] = re.sub(r'(<td></td>)+',collapse, output[nameurl])
lastyear=1976+2+len([t for t in headcounts_byyear if t > 0]) # no expo in 1986 or 2020 or 2021
@@ -157,10 +156,12 @@ table.fancy td.nonempty { background: #eee }
<meta name="keywords" content="NOEDIT">
</head>
<body>
""")
print(f"""
<!-- DO NOT EDIT THIS DOCUMENT BY HAND! It is automatically generated by "scripts/make-folklist.py" -->
<h1>CUCC members and guests in Austria</br> 1976 to %s</h1>
""" % yearnow)
<h1>CUCC members and guests in Austria</br> 1976 to {yearnow}</h1>
""")
print("""
<p>This is a pretty much complete list of all the personnel on %d CUCC
@@ -205,7 +206,12 @@ print(f"""
<hr /><table class="fancy">
""")
print(output)
# This is the main body of the table
table_sorted_by_person = dict(sorted(output.items(), key=lambda item: get_surname(item[0])))
for person in table_sorted_by_person:
print(table_sorted_by_person[person])
print("<tr><td colspan=4><strong>Expo head count</strong></td>", end=' ')
for y in headcounts_byyear: