Update index creation script
This commit is contained in:
parent
fa6e3ab3bb
commit
fdd6a9b75a
|
@ -28,6 +28,28 @@ for root, dirs, files in os.walk(webfile_dir):
|
|||
else:
|
||||
canonical.append(name)
|
||||
|
||||
most_recent = {}
|
||||
for file in sorted(archive):
|
||||
m = re.search("^(\d{{8}}) - (Gun Run {} - .*?)(?:\s*\d+(?:\.\d+)?)?(\.\S+)$".format(year), file, re.IGNORECASE)
|
||||
if m:
|
||||
date = m.group(1)
|
||||
name = m.group(2) + m.group(3)
|
||||
current = most_recent.get(name)
|
||||
if current is None or date > current.get('date'):
|
||||
most_recent[name] = { 'date': date, 'file': file }
|
||||
|
||||
for k, v in most_recent.items():
|
||||
canon = os.path.join(webfile_dir, k)
|
||||
#file = os.path.join(webfile_dir, v.get('file'))
|
||||
# No need for directory, since it's in the same directory
|
||||
file = v.get('file')
|
||||
#print("Creating symlink from {} to {}".format(file, canon))
|
||||
if os.path.isfile(canon):
|
||||
os.unlink(canon)
|
||||
os.symlink(file, canon)
|
||||
if k not in canonical:
|
||||
canonical.append(k)
|
||||
|
||||
indexfile = open(os.path.join(webfile_dir, root, "index.html"), "w")
|
||||
|
||||
output = """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
|
|
Loading…
Reference in New Issue