Take advantage of the fact that find_files now sorts files by timestamp.

This commit is contained in:
Solderpunk 2020-03-17 13:33:38 +01:00
parent 5d95fed964
commit eff47ef24f
1 changed files with 3 additions and 5 deletions

View File

@ -109,14 +109,12 @@ def main():
# Add one entry per .gmi file # Add one entry per .gmi file
files = find_files(args.n) files = find_files(args.n)
latest_update = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc) for n, filename in enumerate(files):
for filename in files:
entry = feed.add_entry() entry = feed.add_entry()
populate_entry_from_file(filename, args.base_url, entry) populate_entry_from_file(filename, args.base_url, entry)
print("Adding {} with title '{}'...".format(filename, entry.title())) print("Adding {} with title '{}'...".format(filename, entry.title()))
if entry.updated() > latest_update: if n == 0:
latest_update = entry.updated() feed.updated(entry.updated())
feed.updated(latest_update)
# Write file # Write file
feed.atom_file(args.output, pretty=True) feed.atom_file(args.output, pretty=True)