Bugfixes for python3:

* Use range instead of xrange
  * Encode unicode objects before hashing
This commit is contained in:
Stefan Ritter 2011-03-23 23:55:14 +01:00
parent 736ea10a1f
commit b8cb97bd6e

View File

@ -39,7 +39,7 @@ line_start_plus = re.compile("^\+.*$")
tab = " "
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]))
return string
@ -294,7 +294,7 @@ if feed_display == "atom":
print("")
j = len(entries)
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, "")
date = entries[i][0]
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 + "<summary>")
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()
if rss_line != "":
print(tab*4 + rss_line)
@ -326,7 +326,7 @@ elif feed_display == "rss":
print("")
j = len(entries)
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, "")
date = time.strftime("%a, %d %b %Y %H:%M:%S %z", time.gmtime(time.mktime(entries[i][0])))
print(tab*2 + "<item>")
@ -336,7 +336,7 @@ elif feed_display == "rss":
print(tab*3 + "<pubDate>%s</pubDate>" % date)
content = open(str(entries[i][1]), "r")
rss_description= ""
for h in xrange(0, int(feed_preview)):
for h in range(0, int(feed_preview)):
line = content.readline().strip()
if line:
rss_description = "%s%s<br />" % (rss_description, line)