From e70f9d6a3e7a658d0a4e6848f23d6f87c8152a19 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 8 Jan 2024 20:15:14 +0100 Subject: Actually, generate those rST files. --- xml2static_rst.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xml2static_rst.py b/xml2static_rst.py index 54989a8..009915c 100644 --- a/xml2static_rst.py +++ b/xml2static_rst.py @@ -3,6 +3,7 @@ from datetime import datetime import logging import sys +from os import mkdir from os.path import basename, exists, normpath, splitext from pprint import pprint from shutil import which @@ -89,14 +90,16 @@ def collect_posts(root: ET.Element, threads: dict) -> dict: print('', file=sys.stderr) return out -# if not os.path.exists('comments/'): -# os.mkdir('comments') if __name__=='__main__': root = init("comments.xml") threads = collect_threads(root) posts = collect_posts(root, threads) + + if not exists('comments/'): + mkdir('comments') + for post in posts: - print('\n' + post) - pprint(posts[post]) + with open(f"comments/{post}.rst", "w") as out_rst: + print(posts[post]['msg'].strip(), file=out_rst) -- cgit