Skip to content

Commit

Permalink
[web,modules,setup] More python 3 compatibility
Browse files Browse the repository at this point in the history
Most modules should now work with Python 3.
Work is in progress to get the rest of them fixed.
  • Loading branch information
Elad Alfassa committed Feb 22, 2014
1 parent 95ba19a commit 2212563
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 0 additions & 4 deletions admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,3 @@ def save_config(bot, trigger):
if not trigger.admin:
return
bot.config.save()


if __name__ == '__main__':
print __doc__.strip()
11 changes: 7 additions & 4 deletions calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
from willie.module import commands, example
from willie.tools import eval_equation
from socket import timeout
import string
import HTMLParser
import sys
if sys.version_info.major < 3:
import HTMLParser
else:
import html.parser as HTMLParser


@commands('c', 'calc')
Expand Down Expand Up @@ -63,7 +66,7 @@ def wa(bot, trigger):
except timeout as e:
return bot.say('[WOLFRAM ERROR] Request timed out')
if answer:
answer = answer.decode('string_escape')
answer = answer.decode('unicode_escape')
answer = HTMLParser.HTMLParser().unescape(answer)
# This might not work if there are more than one instance of escaped
# unicode chars But so far I haven't seen any examples of such output
Expand All @@ -73,7 +76,7 @@ def wa(bot, trigger):
char_code = match.group(1)
char = unichr(int(char_code, 16))
answer = answer.replace('\:' + char_code, char)
waOutputArray = string.split(answer, ";")
waOutputArray = answer.split(";")
if(len(waOutputArray) < 2):
if(answer.strip() == "Couldn't grab results from json stringified precioussss."):
# Answer isn't given in an IRC-able format, just link to it.
Expand Down
2 changes: 1 addition & 1 deletion rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def disable_feed():

try:
fp = feedparser.parse(feed.url, etag=feed.etag, modified=feed.modified)
except IOError, e:
except IOError as e:
bot.debug(__file__, "Can't parse feed on {0}, disabling ({1})".format(
feed.name, str(e)), 'warning')
disable_feed()
Expand Down
9 changes: 6 additions & 3 deletions youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""
youtube.py - Willie YouTube Module
Copyright 2012, Dimitri Molenaars, Tyrope.nl.
Copyright © 2012-2013, Elad Alfassa, <[email protected]>
Copyright © 2012-2014, Elad Alfassa, <[email protected]>
Copyright 2012, Edward Powell, embolalia.net
Licensed under the Eiffel Forum License 2.
Expand All @@ -15,8 +15,11 @@
from willie.module import rule, commands, example
import json
import re
from HTMLParser import HTMLParser

import sys
if sys.version_info.major < 3:
from HTMLParser import HTMLParser
else:
from html.parser import HTMLParser

def setup(bot):
regex = re.compile('(youtube.com/watch\S*v=|youtu.be/)([\w-]+)')
Expand Down

0 comments on commit 2212563

Please sign in to comment.