Bugfixes for python3:
* Use range instead of xrange * Encode unicode objects before hashing
This commit is contained in:
parent
736ea10a1f
commit
b8cb97bd6e
10
blogthon.cgi
10
blogthon.cgi
@ -39,7 +39,7 @@ line_start_plus = re.compile("^\+.*$")
|
|||||||
tab = " "
|
tab = " "
|
||||||
|
|
||||||
def generate_uuid(string):
|
def generate_uuid(string):
|
||||||
string_md5sum = md5(string).hexdigest()
|
string_md5sum = md5(string.encode("utf-8")).hexdigest()
|
||||||
string = str.join("-", (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32]))
|
string = str.join("-", (string_md5sum[0:8], string_md5sum[8:12], string_md5sum[12:16], string_md5sum[16:20], string_md5sum[20:32]))
|
||||||
return string
|
return string
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ if feed_display == "atom":
|
|||||||
print("")
|
print("")
|
||||||
j = len(entries)
|
j = len(entries)
|
||||||
if j > 10: j = 10
|
if j > 10: j = 10
|
||||||
for i in xrange(0, j):
|
for i in range(0, j):
|
||||||
title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "")
|
title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "")
|
||||||
date = entries[i][0]
|
date = entries[i][0]
|
||||||
title_md5sum = generate_uuid(title)
|
title_md5sum = generate_uuid(title)
|
||||||
@ -305,7 +305,7 @@ if feed_display == "atom":
|
|||||||
print(tab*3 + "<updated>%s-%s-%sT%s:%s:%sZ</updated>" % (str(date[0]), month, day, hour, min, sec))
|
print(tab*3 + "<updated>%s-%s-%sT%s:%s:%sZ</updated>" % (str(date[0]), month, day, hour, min, sec))
|
||||||
print(tab*3 + "<summary>")
|
print(tab*3 + "<summary>")
|
||||||
content = open(str(entries[i][1]), "r")
|
content = open(str(entries[i][1]), "r")
|
||||||
for h in xrange(0, int(feed_preview)):
|
for h in range(0, int(feed_preview)):
|
||||||
rss_line = content.readline().strip()
|
rss_line = content.readline().strip()
|
||||||
if rss_line != "":
|
if rss_line != "":
|
||||||
print(tab*4 + rss_line)
|
print(tab*4 + rss_line)
|
||||||
@ -326,7 +326,7 @@ elif feed_display == "rss":
|
|||||||
print("")
|
print("")
|
||||||
j = len(entries)
|
j = len(entries)
|
||||||
if j > 10: j = 10
|
if j > 10: j = 10
|
||||||
for i in xrange(0, j):
|
for i in range(0, j):
|
||||||
title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "")
|
title = str(entries[i][1]).replace(entries_dir, "", 1).replace("." + entries_suffix, "")
|
||||||
date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0])))
|
date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0])))
|
||||||
print(tab*2 + "<item>")
|
print(tab*2 + "<item>")
|
||||||
@ -336,7 +336,7 @@ elif feed_display == "rss":
|
|||||||
print(tab*3 + "<pubDate>%s</pubDate>" % date)
|
print(tab*3 + "<pubDate>%s</pubDate>" % date)
|
||||||
content = open(str(entries[i][1]), "r")
|
content = open(str(entries[i][1]), "r")
|
||||||
rss_description= ""
|
rss_description= ""
|
||||||
for h in xrange(0, int(feed_preview)):
|
for h in range(0, int(feed_preview)):
|
||||||
line = content.readline().strip()
|
line = content.readline().strip()
|
||||||
if line:
|
if line:
|
||||||
rss_description = "%s%s<br />" % (rss_description, line)
|
rss_description = "%s%s<br />" % (rss_description, line)
|
||||||
|
Loading…
Reference in New Issue
Block a user