aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xml2static_rst.py11
1 files 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)