notes/comproc.py
2025-07-16 20:15:53 +01:00

23 lines
960 B
Python

import datetime
import commentslist
commented = []
for comment in commentslist.comments:
commented.append(comment["slug"])
commented = sorted(list(dict.fromkeys(commented)))
for slug in commented:
thefile = open("comm-" + str(slug)[0:4] + "-" + str(slug)[4:6] + "-" + str(slug)[6:8] + ".html","w")
commno = 1
for comment in commentslist.comments:
if comment["slug"] == slug:
thefile.write("<div class=\"comments\">\n<h2>n° " + str(commno) + "</h2>\n<p class=\"commenttime\"><code>" + datetime.datetime.strftime(comment["date"],"%Y-%m-%d") + "</code></p>\n<p>" + comment["body"] + "</p>\n")
try:
if len(comment["reply"]) > 0:
thefile.write("<div class=\"reply\">\n<p><span class=\"replystring\">reply: </span>" + comment["reply"] + "</p>\n</div>\n")
except:
pass
thefile.write("</div>\n")
commno += 1
thefile.close()