From 4bba02ea2c3a55c50170db1c9ee6bd6858be475f Mon Sep 17 00:00:00 2001 From: vanten-s Date: Wed, 6 Sep 2023 09:26:11 +0200 Subject: [PATCH] Added sorting and basic refactoring --- __init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index f1bb03d..1664f2f 100644 --- a/__init__.py +++ b/__init__.py @@ -39,7 +39,9 @@ def article_to_xml(article_path: pathlib.Path): return base_item.format(tags="\n".join(tags)) def make_rss_feed(path, channel_name, channel_link, description): - articles = "".join([article_to_xml(path) for path in (pathlib.Path.cwd() / path).glob("*")]) + article_paths = (pathlib.Path.cwd() / path).glob("[0-9]*") + article_paths_sorted = sorted(article_paths, key=lambda x: x.name, reverse=True) + articles = "".join([article_to_xml(path) for path in article_paths_sorted]) return base_feed \ .replace("{title}", channel_name) \ .replace("{link}", channel_link) \