/usr/share/doc/python-elements/dynamic/add_comment.py is in python-elements 0.13+svn20090823.230+dfsg-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #!/usr/bin/python
# adds comments to the reference files
# [[comment [identifier]]]
from sys import argv
from sys import exit
from os import system
from urllib2 import urlopen
testonly = False
if len(argv) < 2:
print "please add filename of reference html"
exit(0)
if len(argv) == 3:
testonly = True
print testonly
blueprint = open("comment_blueprint.html").read().strip()
blueprint_onlyadd = open("comment_blueprint_onlyadd.html").read().strip()
c = open(argv[1]).read().strip()
c_orig = c
comments = []
while "[[comment" in c:
x = c[c.index("[[comment"):c.index("]]")+2]
c = c[c.index("]]")+2:]
# get comments
s = x.replace("[[comment", "").replace("]]", "").strip()
if testonly:
c_arr = []
comments = ""
else:
url = "http://linuxuser.at/elements/doc/comments.php?action=get_comment&t=%s" % s
comments = urlopen(url).read().strip()
c_arr = comments.split("\n")
if c_arr[0].strip() == "":
c_arr.pop(0)
comments = ""
for cc in c_arr:
cc_arr = cc.split("|||")
comments = "%s\n<tr><th>%s (%s)</th></tr>\n<tr><td>%s</td></tr>\n" % (comments, cc_arr[0], cc_arr[2], cc_arr[1])
if len(c_arr) > 0:
out = blueprint.replace("##name##", s)
else:
out = blueprint_onlyadd.replace("##name##", s)
out = out.replace("##count##", str(len(c_arr)))
out = out.replace("##comments##", comments)
#print comments
c_orig = c_orig.replace(x, out)
c_orig = c_orig.replace("<ul>", "<ul class='ul1'>")
c_orig = c_orig.replace("<ul>", "<ul class='ul1'>")
if testonly:
f = open("../test.html", "w")
f.write(c_orig)
f.close()
system("firefox-bin ../test.html")
system("rm ../test.html")
else:
print c_orig
|