Continue accelerating the 2to3 step (remove fix_print).

This commit is contained in:
Valentin Lorentz 2014-01-20 15:31:09 +01:00
parent 529b8f8d99
commit c1c23f66f4
13 changed files with 61 additions and 58 deletions

View File

@ -89,9 +89,9 @@ class MathTestCase(PluginTestCase):
self.assertError('base 4 4')
self.assertError('base 10 12 A')
print
print "If we have not fixed a bug with Math.base, the following ",
print "tests will hang the test-suite."
print()
print("If we have not fixed a bug with Math.base, the following ")
print("tests will hang the test-suite.")
self.assertRegexp('base 2 10 [base 10 2 -12]', '-12')
self.assertRegexp('base 16 2 [base 2 16 -110101]', '-110101')

View File

@ -131,8 +131,8 @@ class MiscTestCase(ChannelPluginTestCase):
if network:
def testVersion(self):
print '*** This test should start passing when we have our '\
'threaded issues resolved.'
print('*** This test should start passing when we have our '\
'threaded issues resolved.')
self.assertNotError('version')
def testSource(self):

View File

@ -48,10 +48,10 @@ class NewsTestCase(ChannelPluginTestCase):
self.assertRegexp('news', 'subject.*subject2')
self.assertNotError('add 5 subject3: foo3')
self.assertRegexp('news', 'subject3')
print
print 'Sleeping to expire the news item (testAddnews)'
print()
print('Sleeping to expire the news item (testAddnews)')
time.sleep(6)
print 'Done sleeping.'
print('Done sleeping.')
self.assertNotRegexp('news', 'subject3')
def testNews(self):
@ -77,10 +77,10 @@ class NewsTestCase(ChannelPluginTestCase):
self.assertRegexp('old', 'No old news')
self.assertNotError('add 5 foo: bar')
self.assertRegexp('old', 'No old news')
print
print 'Sleeping to expire the news item (testOldnews)'
print()
print('Sleeping to expire the news item (testOldnews)')
time.sleep(6)
print 'Done sleeping.'
print('Done sleeping.')
self.assertNotError('old')

View File

@ -65,9 +65,9 @@ class WebTestCase(ChannelPluginTestCase):
# part of it.
self.assertRegexp('title http://www.n-e-r-d.com/', 'N.*E.*R.*D')
# Checks that the parser doesn't hang on invalid tags
print
print "If we have not fixed a bug with the parser, the following",
print "test will hang the test-suite."
print()
print("If we have not fixed a bug with the parser, the following")
print("test will hang the test-suite.")
self.assertNotError(
'title http://www.youtube.com/watch?v=x4BtiqPN4u8')

View File

@ -155,7 +155,7 @@ try:
'fix_itertools', 'fix_itertools_imports', 'fix_long',
'fix_map', 'fix_metaclass', 'fix_methodattrs',
'fix_numliterals',
'fix_print', 'fix_raise',
'fix_raise',
'fix_reduce', 'fix_renames', 'fix_repr',
'fix_set_literal', 'fix_standarderror', 'fix_sys_exc',
'fix_throw', 'fix_tuple_params', 'fix_types',

View File

@ -1144,9 +1144,9 @@ class DefaultCapabilities(registry.SpaceSeparatedListOfStrings):
def setValue(self, v, allowDefaultOwner=conf.allowDefaultOwner):
registry.SpaceSeparatedListOfStrings.setValue(self, v)
if '-owner' not in self.value and not allowDefaultOwner:
print '*** You must run supybot with the --allow-default-owner'
print '*** option in order to allow a default capability of owner.'
print '*** Don\'t do that, it\'s dumb.'
print('*** You must run supybot with the --allow-default-owner')
print('*** option in order to allow a default capability of owner.')
print('*** Don\'t do that, it\'s dumb.')
self.value.add('-owner')
conf.registerGlobalValue(conf.supybot, 'capabilities',

View File

@ -36,6 +36,7 @@ work in an IRC-case-insensitive fashion), and numerous other things.
"""
from __future__ import division
from __future__ import print_function
import re
import sys
@ -51,7 +52,7 @@ from itertools import imap
def debug(s, *args):
"""Prints a debug string. Most likely replaced by our logging debug."""
print '***', s % args
print('***', s % args)
userHostmaskRe = re.compile(r'^\S+!\S+@\S+$')
def isUserHostmask(s):

View File

@ -95,9 +95,9 @@ class StdoutStreamHandler(logging.StreamHandler):
# We check for ERROR there because otherwise, tracebacks (which are
# already wrapped by Python itself) wrap oddly.
if not isinstance(record.levelname, basestring):
print record
print record.levelname
print utils.stackTrace()
print(record)
print(record.levelname)
print(utils.stackTrace())
prefixLen = len(record.levelname) + 1 # ' '
s = textwrap.fill(s, width=78, subsequent_indent=' '*prefixLen)
s.rstrip('\r\n')

View File

@ -29,7 +29,7 @@
"""Handles interactive questions; useful for wizards and whatnot."""
from __future__ import print_function
import sys
import textwrap
@ -44,8 +44,8 @@ useBold = False
def output(s, unformatted=True, fd=sys.stdout):
if unformatted:
s = textwrap.fill(utils.str.normalizeWhitespace(s), width=65)
print >>fd, s
print >>fd
print(s, file=fd)
print('', file=fd)
def expect(prompt, possibilities, recursed=False, default=None,
acceptEmpty=False, fd=sys.stdout):
@ -75,13 +75,13 @@ def expect(prompt, possibilities, recursed=False, default=None,
prompt = prompt.strip() + ' '
if useBold:
prompt += ansi.RESET
print >>fd, ansi.BOLD,
print(ansi.BOLD, end=' ', file=fd)
if sys.version_info[0] >= 3:
s = input(prompt)
else:
s = raw_input(prompt)
s = s.strip()
print >>fd
print(file=fd)
if possibilities:
if s in possibilities:
return s
@ -143,7 +143,7 @@ def getpass(prompt=None, secondPrompt=None):
output(_('Passwords don\'t match.'))
else:
break
print
print('')
return password

View File

@ -42,11 +42,11 @@ _ = i18n.PluginInternationalization()
def error(s):
"""Replace me with something better from another module!"""
print '***', s
print('***', s)
def exception(s):
"""Ditto!"""
print '***', s, 'A bad exception.'
print('***', s, 'A bad exception.')
class RegistryException(Exception):
pass

View File

@ -31,13 +31,13 @@ class shlex:
self.filestack = []
self.source = None
if self.debug:
print 'shlex: reading from %s, line %d' \
% (self.instream, self.lineno)
print('shlex: reading from %s, line %d' \
% (self.instream, self.lineno))
def push_token(self, tok):
"Push a token onto the stack popped by the get_token method"
if self.debug >= 1:
print "shlex: pushing token " + `tok`
print("shlex: pushing token " + `tok`)
self.pushback = [tok] + self.pushback
def push_source(self, newstream, newfile=None):
@ -48,9 +48,9 @@ class shlex:
self.lineno = 1
if self.debug:
if newfile is not None:
print 'shlex: pushing to file %s' % (self.infile,)
print('shlex: pushing to file %s' % (self.infile,))
else:
print 'shlex: pushing to stream %s' % (self.instream,)
print('shlex: pushing to stream %s' % (self.instream,))
def pop_source(self):
"Pop the input source stack."
@ -58,8 +58,8 @@ class shlex:
(self.infile, self.instream, self.lineno) = self.filestack[0]
self.filestack = self.filestack[1:]
if self.debug:
print 'shlex: popping to %s, line %d' \
% (self.instream, self.lineno)
print('shlex: popping to %s, line %d' \
% (self.instream, self.lineno))
self.state = ' '
def get_token(self):
@ -68,7 +68,7 @@ class shlex:
tok = self.pushback[0]
self.pushback = self.pushback[1:]
if self.debug >= 1:
print "shlex: popping token " + `tok`
print("shlex: popping token " + `tok`)
return tok
# No pushback. Get a token.
raw = self.read_token()
@ -89,9 +89,9 @@ class shlex:
# Neither inclusion nor EOF
if self.debug >= 1:
if raw:
print "shlex: token=" + `raw`
print("shlex: token=" + `raw`)
else:
print "shlex: token=EOF"
print("shlex: token=EOF")
return raw
def read_token(self):
@ -101,8 +101,8 @@ class shlex:
if nextchar == '\n':
self.lineno = self.lineno + 1
if self.debug >= 3:
print "shlex: in state", repr(self.state), \
"I see character:", repr(nextchar)
print("shlex: in state", repr(self.state), \
"I see character:", repr(nextchar))
if self.state is None:
self.token = '' # past end of file
break
@ -112,7 +112,7 @@ class shlex:
break
elif nextchar in self.whitespace:
if self.debug >= 2:
print "shlex: I see whitespace in whitespace state"
print("shlex: I see whitespace in whitespace state")
if self.token:
break # emit current token
else:
@ -147,7 +147,7 @@ class shlex:
self.backslash = False
elif not nextchar: # end of file
if self.debug >= 2:
print "shlex: I see EOF in quotes state"
print("shlex: I see EOF in quotes state")
# XXX what error should be raised here?
raise ValueError, "No closing quotation"
elif self.state == 'a':
@ -156,7 +156,7 @@ class shlex:
break
elif nextchar in self.whitespace:
if self.debug >= 2:
print "shlex: I see whitespace in word state"
print("shlex: I see whitespace in word state")
self.state = ' '
if self.token:
break # emit current token
@ -170,7 +170,7 @@ class shlex:
else:
self.pushback = [nextchar] + self.pushback
if self.debug >= 2:
print "shlex: I see punctuation in word state"
print("shlex: I see punctuation in word state")
self.state = ' '
if self.token:
break # emit current token
@ -180,9 +180,9 @@ class shlex:
self.token = ''
if self.debug > 1:
if result:
print "shlex: raw token=" + `result`
print("shlex: raw token=" + `result`)
else:
print "shlex: raw token=EOF"
print("shlex: raw token=EOF")
return result
def sourcehook(self, newfile):
@ -213,6 +213,6 @@ if __name__ == '__main__':
while True:
tt = lexer.get_token()
if tt:
print "Token: " + repr(tt)
print("Token: " + repr(tt))
else:
break

View File

@ -147,8 +147,8 @@ class PluginTestCase(SupyTestCase):
for cb in self.irc.callbacks:
cbModule = sys.modules[cb.__class__.__module__]
if hasattr(cbModule, 'deprecated') and cbModule.deprecated:
print
print 'Ignored, %s is deprecated.' % cb.name()
print('')
print('Ignored, %s is deprecated.' % cb.name())
run = False
if run:
originalRunTest()
@ -238,7 +238,7 @@ class PluginTestCase(SupyTestCase):
if timeout is None:
timeout = self.timeout
if self.myVerbose:
print # Extra newline, so it's pretty.
print('') # Extra newline, so it's pretty.
prefixChars = conf.supybot.reply.whenAddressedBy.chars()
if not usePrefixChar and query[0] in prefixChars:
query = query[1:]
@ -246,7 +246,7 @@ class PluginTestCase(SupyTestCase):
query = query.encode('utf8') # unicode->str
msg = ircmsgs.privmsg(to, query, prefix=frm)
if self.myVerbose:
print 'Feeding: %r' % msg
print('Feeding: %r' % msg)
self.irc.feedMsg(msg)
fed = time.time()
response = self.irc.takeMsg()
@ -255,7 +255,7 @@ class PluginTestCase(SupyTestCase):
drivers.run()
response = self.irc.takeMsg()
if self.myVerbose:
print 'Response: %r' % response
print('Response: %r' % response)
return response
def getMsg(self, query, **kwargs):
@ -433,7 +433,7 @@ class ChannelPluginTestCase(PluginTestCase):
if timeout is None:
timeout = self.timeout
if self.myVerbose:
print # Newline, just like PluginTestCase.
print('') # Newline, just like PluginTestCase.
prefixChars = conf.supybot.reply.whenAddressedBy.chars()
if query[0] not in prefixChars and usePrefixChar:
query = prefixChars[0] + query
@ -441,7 +441,7 @@ class ChannelPluginTestCase(PluginTestCase):
query = query.encode('utf8') # unicode->str
msg = ircmsgs.privmsg(to, query, prefix=frm)
if self.myVerbose:
print 'Feeding: %r' % msg
print('Feeding: %r' % msg)
self.irc.feedMsg(msg)
fed = time.time()
response = self.irc.takeMsg()
@ -466,7 +466,7 @@ class ChannelPluginTestCase(PluginTestCase):
else:
ret = None
if self.myVerbose:
print 'Returning: %r' % ret
print('Returning: %r' % ret)
return ret
def feedMsg(self, query, to=None, frm=None, private=False):

View File

@ -28,6 +28,8 @@
# POSSIBILITY OF SUCH DAMAGE.
###
from __future__ import print_function
import os
import sys
import ast
@ -345,7 +347,7 @@ def callTracer(fd=None, basename=True):
filename = code.co_filename
if basename:
filename = os.path.basename(filename)
print >>fd, '%s: %s(%s)' % (filename, funcname, lineno)
print('%s: %s(%s)' % (filename, funcname, lineno), file=fd)
return tracer
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: