aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Ritter <xeno@thehappy.de>2011-03-23 23:55:14 +0100
committerStefan Ritter <xeno@thehappy.de>2011-03-23 23:55:14 +0100
commitb8cb97bd6e2f7232eb19d7cffff01dde7c2535f9 (patch)
tree9051e81f0d70378a1ff5e5e357d76767fe357f95
parent736ea10a1f3a4934d59c23fa908f627831d5d347 (diff)
Bugfixes for python3:
* Use range instead of xrange * Encode unicode objects before hashing
-rwxr-xr-xblogthon.cgi10
1 files changed, 5 insertions, 5 deletions
diff --git a/blogthon.cgi b/blogthon.cgi
index 1c7c8db..a90ff88 100755
--- a/blogthon.cgi
+++ b/blogthon.cgi
@@ -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)