From 800b78a02fcc1ddec5c1581e7f0a05b0a231e67b Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 22 Sep 2011 15:04:19 -0400 Subject: [PATCH] more python3 fixes --- bot.py | 2 +- irc.py | 5 +++-- modules/calc.py | 5 ++--- modules/weather.py | 8 ++++---- phenny | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bot.py b/bot.py index b794913..3c34950 100755 --- a/bot.py +++ b/bot.py @@ -228,7 +228,7 @@ class Phenny(irc.Bot): t.start() else: self.call(func, origin, phenny, input) - for source in [origin.sender, origin.nick]: + for source in [decode(origin.sender), decode(origin.nick)]: try: self.stats[(func.name, source)] += 1 except KeyError: self.stats[(func.name, source)] = 1 diff --git a/irc.py b/irc.py index 266ad04..9f3acd5 100755 --- a/irc.py +++ b/irc.py @@ -52,6 +52,7 @@ class Bot(asynchat.async_chat): def __write(self, args, text=None): # print '%r %r %r' % (self, args, text) + print(args, text) try: if text is not None: self.push((b' '.join(args) + b' :' + text)[:512] + b'\r\n') @@ -61,8 +62,7 @@ class Bot(asynchat.async_chat): pass def write(self, args, text=None): - print(args, text) - # This is a safe version of __write + """This is a safe version of __write""" def safe(input): input = input.replace('\n', '') input = input.replace('\r', '') @@ -118,6 +118,7 @@ class Bot(asynchat.async_chat): def found_terminator(self): line = self.buffer + print(line) if line.endswith(b'\r'): line = line[:-1] self.buffer = b'' diff --git a/modules/calc.py b/modules/calc.py index fcea71b..58b59e3 100755 --- a/modules/calc.py +++ b/modules/calc.py @@ -79,9 +79,8 @@ def c(phenny, input): parts = bytes.split('",') answer = [p for p in parts if p.startswith('rhs: "')][0][6:] if answer: - answer = answer.decode('unicode-escape') - answer = ''.join(chr(ord(c)) for c in answer) - answer = answer.decode('utf-8') + #answer = ''.join(chr(ord(c)) for c in answer) + #answer = answer.decode('utf-8') answer = answer.replace('\xc2\xa0', ',') answer = answer.replace('', '^(') answer = answer.replace('', ')') diff --git a/modules/weather.py b/modules/weather.py index 1f0c908..4ecadcb 100755 --- a/modules/weather.py +++ b/modules/weather.py @@ -220,10 +220,10 @@ def f_weather(self, origin, match, args): description = 'Violent storm' else: description = 'Hurricane' - degrees = float(wind[0:3] - if degrees == 'VRB': - degrees = '\u21BB' - elif (degrees <= 22.5) or (degrees > 337.5): + degrees = float(wind[0:3]) + #if degrees == 'VRB': + # degrees = '\u21BB' + if (degrees <= 22.5) or (degrees > 337.5): degrees = '\u2191' elif (degrees > 22.5) and (degrees <= 67.5): degrees = '\u2197' diff --git a/phenny b/phenny index 9a8857b..cf4a02b 100755 --- a/phenny +++ b/phenny @@ -17,8 +17,8 @@ from textwrap import dedent as trim dotdir = os.path.expanduser('~/.phenny') def check_python_version(): - if sys.version_info < (2, 4): - error = 'Error: Requires Python 2.4 or later, from www.python.org' + if sys.version_info < (3, 0): + error = 'Error: Requires Python 3.0 or later, from www.python.org' print(error, file=sys.stderr) sys.exit(1)