From 7ec2d58f45bc3c0a971dc52835d0475802d54b31 Mon Sep 17 00:00:00 2001 From: Eloi Date: Thu, 4 Sep 2025 11:56:17 +0200 Subject: [PATCH] cleaning --- src/check-settings.py | 3 +-- src/microblog.py | 3 +++ src/rss.py | 13 ++++++------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/check-settings.py b/src/check-settings.py index efa6891..1322462 100644 --- a/src/check-settings.py +++ b/src/check-settings.py @@ -1,4 +1,3 @@ - import os, argparse from tomlkit import loads from tomlkit import dump @@ -34,7 +33,7 @@ class MicroblogConfig: def check(self, r, u): # (reference, user) for key in r: - if key == "latestpages": continue; + if key == "latestpages": continue # post and webring have subtables # webring.profile # webring.following diff --git a/src/microblog.py b/src/microblog.py index f2ba260..51aff70 100644 --- a/src/microblog.py +++ b/src/microblog.py @@ -550,6 +550,9 @@ if __name__ == "__main__": updated += writepage(tpl, tl, tc, cfg["page"], paginate=True if new_posts is None else False) if cfg["rss"]["enabled"]: + # ensure output directory for feeds exists + if not os.path.exists("feeds"): + os.mkdir("feeds") feed_filename = "feeds/__index__.xml" rss.write_feed( p[:cfg["rss"]["limit"]], \ diff --git a/src/rss.py b/src/rss.py index cba2fbb..c10aa32 100644 --- a/src/rss.py +++ b/src/rss.py @@ -1,4 +1,3 @@ - from microblog import My_Html_Parser # from html.parser import HTMLParser from html import escape @@ -7,7 +6,7 @@ try: import feedgenerator except ImportError: traceback.print_exc() - def write_feed(posts, filename, params): + def write_feed(posts, filename, params, tagname=None): pass print("\trss disabled - missing dependency", file=sys.stderr) print("\tYour microblog still may have been generated.", file=sys.stderr) @@ -22,7 +21,7 @@ def line2words(lines, limit): l = len(word) if limit > 0 and (l + char_count > limit): break_outer_loop = True - break; + break output.append(word) char_count += l if break_outer_loop: @@ -35,10 +34,10 @@ def line2words(lines, limit): output.append("...") return output -# this is similar tot he markup function in microblog +# this is similar to the markup function in microblog def enrich_msg(lines, is_atom=True): if not is_atom: - return string + return lines content = [] parser = My_Html_Parser([]) for line in lines: @@ -66,9 +65,9 @@ def enrich_msg(lines, is_atom=True): content.append(line) return content -def write_feed(posts, filename, params, tagname=str()): +def write_feed(posts, filename, params, tagname=None): feed = None - if tagname != str(): + if tagname: t = params["title_tagged"].format( __tagname__ = tagname, __title__ = params["title"]) -- 2.30.2