Jason R. Coombs avatar Jason R. Coombs committed 0b1ec86 Draft

Use print function throughout

Comments (0)

Files changed (4)

pmxbot/botbase.py

 # vim:ts=4:sw=4:noexpandtab
 
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import sys
 import datetime
 			try:
 				func(client=c, event=e, nick=nick, channel=channel)
 			except Exception:
-				print >> sys.stderr, datetime.datetime.now(), "Error in on_join handler %s" % func
+				print(datetime.datetime.now(),
+					"Error in on_join handler %s" % func,
+					file=sys.stderr)
 				traceback.print_exc()
 
 		if channel in self._nolog or nick == self._nickname:
 		Wrapper to run scheduled type tasks cleanly.
 		"""
 		def on_error(exception):
-			print datetime.datetime.now(), "Error in background runner for ", func
+			print(datetime.datetime.now(), "Error in background runner for ",
+				func)
 			traceback.print_exc()
 		func = functools.partial(func, c, None, *args)
 		self._handle_output(channel, pmxbot.itertools.trap_exceptions(
 			on_error))
 
 	def _handle_exception(self, exception, **kwargs):
-		explitives = ['Yikes!', 'Zoiks!', 'Ouch!']
-		explitive = random.choice(explitives)
-		res = ["{explitive} An error occurred: {exception}"
+		expletives = ['Yikes!', 'Zoiks!', 'Ouch!']
+		expletive = random.choice(expletives)
+		res = ["{expletive} An error occurred: {exception}"
 			.format(**vars())]
 		res.append('!{name} {doc}'.format(**kwargs))
-		print datetime.datetime.now(), ("Error with command {type}"
+		print(datetime.datetime.now(), "Error with command {type}"
 			.format(**kwargs))
 		traceback.print_exc()
 		return res
 # -*- coding: utf-8 -*-
 # vim:ts=4:sw=4:noexpandtab
 # c-basic-indent: 4; tab-width: 4; indent-tabs-mode: true;
-from __future__ import absolute_import
+from __future__ import absolute_import, print_function
 
 import socket
 import re
 			db = init_feedparser_db(self.db_uri)
 			db.add_entries(entries)
 		except Exception, e:
-			print datetime.datetime.now(), \
-				"Oh crap, couldn't add_feed_entries"
-			print e
+			print(datetime.datetime.now(),
+				"Oh crap, couldn't add_feed_entries")
+			print(e)
 
 class FeedparserDB(storage.SelectableStorage):
 	pass

tests/functional/__init__.py

+from __future__ import print_function
+
 import subprocess
 import os
 import sys
 			message = message,
 			))
 		res = cursor.fetchall()
-		print res
+		print(res)
 		return len(res) >= 1
 
 	@classmethod

tests/unit/test_commands.py

 # -*- coding: utf-8 -*-
+from __future__ import print_function
+
 import re
 import os
 import uuid
 		Basic google search for "pmxbot". Result must contain a link.
 		"""
 		res = pmxbot.google(c, e, "#test", "testrunner", "pmxbot")
-		print res
+		print(res)
 		assert "http" in res
 
 	@pytest.has_internet
 		Basic google calculator command - 1+1 must include 2 in results
 		"""
 		res = pmxbot.googlecalc(c, e, "#test", "testrunner", "1+1")
-		print res
+		print(res)
 		assert "2" in res
 
 	@pytest.has_internet
 		include 151.4 in results
 		"""
 		res = pmxbot.googlecalc(c, e, "#test", "testrunner", "40 gallons in liters")
-		print res
+		print(res)
 		assert "151.4" in res
 
 	@pytest.has_internet
 		Test that google calculator for a currency conversion: 1 USD in GBP
 		"""
 		res = pmxbot.googlecalc(c, e, "#test", "testrunner", "1 USD in GBP")
-		print res
+		print(res)
 		assert re.match(r"""1 (?:US|U\.S\.) dollars? = \d\.\d+ British pounds?(?: sterling)?""", res)
 
 	@pytest.has_internet
 		Test that google calculator for a currency conversion: 12 CZK in euros
 		"""
 		res = pmxbot.googlecalc(c, e, "#test", "testrunner", "12 CZK in euros")
-		print res
+		print(res)
 		assert re.match(r"""12 Czech(?: Republic)? [Kk]orun(?:a|y)s? = \d\.\d+ [Ee]uros?""", res)
 
 	# time patterns come as 4:20pm when queried from the U.S. and 16:20
 		"""
 		res = pmxbot.weather(c, e, "#test", "testrunner", "Washington, DC")
 		for line in res:
-			print line
+			print(line)
 			assert re.match(r""".+\. Currently: (?:-)?[0-9]{1,3}F/(?:-)?[0-9]{1,2}C, .+\.\W+[A-z]{3}: (?:-)?[0-9]{1,3}F/(?:-)?[0-9]{1,2}C, """, line)
 
 	def test_weather_three(self):
 		"""
 		res = pmxbot.weather(c, e, "#test", "testrunner", "Washington, DC | Palo Alto, CA | London")
 		for line in res:
-			print line
+			print(line)
 			assert re.match(r""".+\. Currently: (?:-)?[0-9]{1,3}F/(?:-)?[0-9]{1,2}C, .+\.\W+[A-z]{3}: (?:-)?[0-9]{1,3}F/(?:-)?[0-9]{1,2}C, """, line)
 
 	def test_weather_all(self):
 		"""
 		res = pmxbot.weather(c, e, "#test", "testrunner", "all")
 		for line in res:
-			print line
+			print(line)
 			assert re.match(r""".+\. Currently: (?:-)?[0-9]{1,3}F/(?:-)?[0-9]{1,2}C, .+\.\W+[A-z]{3}: (?:-)?[0-9]{1,3}F/(?:-)?[0-9]{1,2}C, """, line)
 
 	def test_boo(self):
 		GOOG at 4:00pm (ET): 484.81 (1.5%)
 		"""
 		res = pmxbot.ticker(c, e, "#test", "testrunner", "goog")
-		print res
+		print(res)
 		assert re.match(r"""^GOOG at \d{1,2}:\d{2}(?:am|pm) \([A-z]{1,3}\): \d{2,4}.\d{1,4} \(\-?\d{1,3}.\d%\)$""", res), res
 
 	@pytest.has_internet
 		YOU.L at 10:37am (ET): 39.40 (0.4%)
 		"""
 		res = pmxbot.ticker(c, e, "#test", "testrunner", "you.l")
-		print res
+		print(res)
 		assert re.match(r"""^YOU.L at \d{1,2}:\d{2}(?:am|pm) \([A-z]{1,3}\): \d{1,4}.\d{2,4} \(\-?\d{1,3}.\d%\)$""", res), res
 
 	@pytest.has_internet
 		^IXIC at 10:37am (ET): 2490.40 (0.4%)
 		"""
 		res = pmxbot.ticker(c, e, "#test", "testrunner", "^ixic")
-		print res
+		print(res)
 		assert re.match(r"""^\^IXIC at \d{1,2}:\d{2}(?:am|pm) \([A-z]{1,3}\): \d{4,5}.\d{2} \(\-?\d{1,3}.\d%\)$""", res), res
 
 	def test_pick_or(self):
 		Test the built-in python calculator with a simple expression - 2+2
 		"""
 		res = pmxbot.calc(c, e, "#test", "testrunner", "2+2")
-		print res
+		print(res)
 		assert res == "4"
 
 	def test_calc_complex(self):
 		((((781**2)*5)/92835.3)+4)**0.5
 		"""
 		res = pmxbot.calc(c, e, "#test", "testrunner", "((((781**2)*5)/92835.3)+4)**0.5")
-		print res
+		print(res)
 		assert res.startswith("6.070566")
 
 	@pytest.has_internet
 		Test the progress bar
 		"""
 		res = pmxbot.progress(c, e, "#test", "testrunner", "1|98123|30")
-		print res
+		print(res)
 		assert res == "1 [===       ] 98123"
 
 	def test_strategy(self):
 		Test the social strategy thingie
 		"""
 		res = pmxbot.strategy(c, e, "#test", "testrunner", "")
-		print res
+		print(res)
 		assert res != ""
 
 	@pytest.has_internet
 		pytest.xfail("a.libpa.st is down")
 		person = str(uuid.uuid4())[:9]
 		res = pmxbot.paste(c, e, '#test', person, '')
-		print res
+		print(res)
 		assert res == "hmm.. I didn't find a recent paste of yours, %s. Checkout http://a.libpa.st/" % person
 
 	@pytest.has_internet
 		"""
 		bitcher = "all y'all"
 		res = pmxbot.bitchingisuseless(c, e, '#test', 'testrunner', bitcher)
-		print res
+		print(res)
 		assert res == "Quiet bitching is useless, all y'all. Do something about it."
 
 	def test_qbiu_blank(self):
 		Test the qbiu function with a specified person.
 		"""
 		res = pmxbot.bitchingisuseless(c, e, '#test', 'testrunner', '')
-		print res
+		print(res)
 		assert res == "Quiet bitching is useless, foo'. Do something about it."
 
 	def test_excuse(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.