Process comments from a file
This commit is contained in:
parent
e03e20aabf
commit
ca068b23f0
5 changed files with 41 additions and 9 deletions
23
comproc.py
Normal file
23
comproc.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
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()
|
Loading…
Add table
Add a link
Reference in a new issue