aboutsummaryrefslogtreecommitdiffstats
path: root/xml2static_rst.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-01-08 20:15:14 +0100
committerMatěj Cepl <mcepl@cepl.eu>2024-01-08 20:15:14 +0100
commite70f9d6a3e7a658d0a4e6848f23d6f87c8152a19 (patch)
treec93013be20611419497901d730cd8d7ed750be54 /xml2static_rst.py
parentb99d275ae0cdd159465e8284fb8a92780a27b4b4 (diff)
downloaddisqus_xml2static_rst-e70f9d6a3e7a658d0a4e6848f23d6f87c8152a19.tar.gz
Actually, generate those rST files.HEADmaster
Diffstat (limited to 'xml2static_rst.py')
-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)