Update marshal position data

This commit is contained in:
Timothy Allen 2023-09-14 23:12:16 +02:00
parent 11e30aa5ff
commit 621c8842b1
6 changed files with 29017 additions and 28989 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +1,17 @@
#!/usr/bin/python3
import glob, fileinput, os, re, shutil, sys, tempfile, time
import pprint
year = 2023
webfile_dir = "~/public_html/GunRun{}/".format(year)
print("NOTE: year is {}".format(year))
def natural_sort(l):
convert = lambda text: int(text) if text.isdigit() else text.lower()
alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)]
return sorted(l, key=alphanum_key)
webfile_dir = os.path.expanduser(webfile_dir)
for root, dirs, files in os.walk(webfile_dir):
documents=[]
@ -29,7 +35,7 @@ for root, dirs, files in os.walk(webfile_dir):
canonical.append(name)
most_recent = {}
for file in sorted(archive):
for file in natural_sort(archive):
m = re.search("^(\d{{8}}) - (Gun Run {} - .*?)(?:\s*\d+(?:\.\d+)?)?(\.\S+)$".format(year), file, re.IGNORECASE)
if m:
date = m.group(1)
@ -63,7 +69,7 @@ for root, dirs, files in os.walk(webfile_dir):
if canonical:
output += """<p>Maps</p><ul>"""
for link in sorted(canonical):
for link in natural_sort(canonical):
overview=re.search("Marshal overview", link)
if overview is not None:
continue
@ -77,7 +83,7 @@ for root, dirs, files in os.walk(webfile_dir):
if dirs:
output +="""<p>Clubs</p><ul>"""
dirs.sort()
natural_sort(dirs)
for link in dirs:
if not os.path.islink(link):
output += """<li><a href="{}">{}</a></li>""".format(link, link)
@ -85,7 +91,8 @@ for root, dirs, files in os.walk(webfile_dir):
if archive:
archive=[i.split(' - ') for i in archive]
archive.sort(key=lambda line: (line[2],line[0]))
#archive.sort(key=lambda x: (x[2], x[0]))
archive.sort(key=lambda x: (re.split('\s*v?[\d\.]+\w+$', x[2])[0], x[0]))
archive = [' - '.join(i) for i in archive]
output +="""<p>Source Maps</p><ul>"""
@ -97,7 +104,7 @@ for root, dirs, files in os.walk(webfile_dir):
output +="""<p>Marshal maps</p><table style="border-collapse: collapse;">"""
marshals.sort(key=lambda x: int(re.sub('^.*_(\d+)\..{3,6}?$', '\g<1>', x)))
positions={}
for link in marshals:
for link in natural_sort(marshals):
m = re.search('^(.*?).(pdf|png|jpg|jpeg)$', link)
if m is not None:
positions.setdefault(m.group(1), {})[m.group(2)] = link
@ -122,4 +129,5 @@ for root, dirs, files in os.walk(webfile_dir):
indexfile.write(output)
indexfile.close()
# vim: set expandtab shiftwidth=4 softtabstop=4 :