summaryrefslogtreecommitdiff
path: root/paste
diff options
context:
space:
mode:
authorCyril Roelandt <cyril.roelandt@enovance.com>2014-03-18 12:49:27 +0100
committerCyril Roelandt <cyril.roelandt@enovance.com>2014-03-18 12:49:27 +0100
commit9789a96ca9aab44bd71fdcfc5c0bed1ef7cf0838 (patch)
tree543718d130e12237d431dc61a3ce62769ff1c312 /paste
parent4bdb495a250dc8b44309a8d158fb60a8106e3287 (diff)
downloadpaste-9789a96ca9aab44bd71fdcfc5c0bed1ef7cf0838.tar.gz
Python 3: add parenthesis to print() to support Python 2 and Python 3
Use also "from __future__ import print_function".
Diffstat (limited to 'paste')
-rwxr-xr-xpaste/debug/debugapp.py4
-rw-r--r--paste/evalexception/middleware.py3
-rw-r--r--paste/fixture.py30
-rw-r--r--paste/util/PySourceColor.py4
-rw-r--r--paste/util/intset.py38
-rw-r--r--paste/util/ip4.py12
6 files changed, 48 insertions, 43 deletions
diff --git a/paste/debug/debugapp.py b/paste/debug/debugapp.py
index 190cbdd..8c7c7c2 100755
--- a/paste/debug/debugapp.py
+++ b/paste/debug/debugapp.py
@@ -41,7 +41,7 @@ class SlowConsumer(object):
remaining = int(total)
while remaining > 0:
if self.progress:
- print "%s of %s remaining" % (remaining, total)
+ print("%s of %s remaining" % (remaining, total))
if remaining > 4096:
chunk = environ['wsgi.input'].read(4096)
else:
@@ -59,7 +59,7 @@ class SlowConsumer(object):
'<input type="file" name="file">\n'
'<input type="submit" >\n'
'</form></body></html>\n')
- print "bingles"
+ print("bingles")
start_response("200 OK", [('Content-Type', 'text/html'),
('Content-Length', len(body))])
return [body]
diff --git a/paste/evalexception/middleware.py b/paste/evalexception/middleware.py
index 455758a..d577003 100644
--- a/paste/evalexception/middleware.py
+++ b/paste/evalexception/middleware.py
@@ -24,6 +24,9 @@ can look for the header X-Debug-URL in your 500 responses if you want
to see the full debuggable traceback. Also, this URL is printed to
``wsgi.errors``, so you can open it up in another browser window.
"""
+
+from __future__ import print_function
+
import sys
import os
import cgi
diff --git a/paste/fixture.py b/paste/fixture.py
index f3140ec..7a684e5 100644
--- a/paste/fixture.py
+++ b/paste/fixture.py
@@ -9,6 +9,8 @@ for testing WSGI applications, and the `TestFileEnvironment
effects of command-line scripts.
"""
+from __future__ import print_function
+
import sys
import random
import mimetypes
@@ -687,7 +689,7 @@ class TestResponse(object):
def printlog(s):
if verbose:
- print s
+ print(s)
found_links = []
total_links = 0
@@ -821,14 +823,14 @@ class TestResponse(object):
"The only keyword argument allowed is 'no'")
for s in strings:
if not s in self:
- print >> sys.stderr, "Actual response (no %r):" % s
- print >> sys.stderr, self
+ print("Actual response (no %r):" % s, file=sys.stderr)
+ print(self, file=sys.stderr)
raise IndexError(
"Body does not contain string %r" % s)
for no_s in no:
if no_s in self:
- print >> sys.stderr, "Actual response (has %r)" % no_s
- print >> sys.stderr, self
+ print("Actual response (has %r)" % no_s, file=sys.stderr)
+ print(self, file=sys.stderr)
raise IndexError(
"Body contains string %r" % s)
@@ -1409,8 +1411,8 @@ class TestFileEnvironment(object):
files_before=files_before,
files_after=files_after)
if printresult:
- print result
- print '-'*40
+ print(result)
+ print('-'*40)
if not expect_error:
result.assert_no_error()
if not expect_stderr:
@@ -1536,8 +1538,8 @@ class ProcResult(object):
def assert_no_stderr(self):
__tracebackhide__ = True
if self.stderr:
- print 'Error output:'
- print self.stderr
+ print('Error output:')
+ print(self.stderr)
raise AssertionError("stderr output not expected")
def __str__(self):
@@ -1617,11 +1619,11 @@ class FoundFile(object):
def mustcontain(self, s):
__tracebackhide__ = True
- bytes = self.bytes
- if s not in bytes:
- print 'Could not find %r in:' % s
- print bytes
- assert s in bytes
+ bytes_ = self.bytes
+ if s not in bytes_:
+ print('Could not find %r in:' % s)
+ print(bytes_)
+ assert s in bytes_
def __repr__(self):
return '<%s %s:%s>' % (
diff --git a/paste/util/PySourceColor.py b/paste/util/PySourceColor.py
index 9de5b84..c2a9363 100644
--- a/paste/util/PySourceColor.py
+++ b/paste/util/PySourceColor.py
@@ -664,7 +664,7 @@ def Usage():
python PySourceColor.py -i- -o c:/pydoc.py.html -s < c:/Python22/my.py
_____________________________________________________________________________
"""
- print doc % (__version__)
+ print(doc % (__version__))
sys.exit(1)
###################################################### Command line interface
@@ -1172,7 +1172,7 @@ def showpage(path):
def _printinfo(message, quiet):
"""Helper to print messages"""
if not quiet:
- print message
+ print(message)
def escape(text):
"""escape text for html. similar to cgi.escape"""
diff --git a/paste/util/intset.py b/paste/util/intset.py
index 3873c75..7c7e331 100644
--- a/paste/util/intset.py
+++ b/paste/util/intset.py
@@ -489,23 +489,23 @@ if __name__ == "__main__":
x = IntSet((10,20),30)
y = IntSet((10,20))
z = IntSet((10,20),30,(15,19),min=0,max=40)
- print x
- print x&110
- print x|110
- print x^(15,25)
- print x-12
- print 12 in x
- print x.issubset(x)
- print y.issubset(x)
- print x.istruesubset(x)
- print y.istruesubset(x)
+ print(x)
+ print(x&110)
+ print(x|110)
+ print(x^(15,25))
+ print(x-12)
+ print(12 in x)
+ print(x.issubset(x))
+ print(y.issubset(x))
+ print(x.istruesubset(x))
+ print(y.istruesubset(x))
for val in x:
- print val
- print x.inverse()
- print x == z
- print x == y
- print x <> y
- print hash(x)
- print hash(z)
- print len(x)
- print x.len()
+ print(val)
+ print(x.inverse())
+ print(x == z)
+ print(x == y)
+ print(x != y)
+ print(hash(x))
+ print(hash(z))
+ print(len(x))
+ print(x.len())
diff --git a/paste/util/ip4.py b/paste/util/ip4.py
index b0dfde8..acff6ab 100644
--- a/paste/util/ip4.py
+++ b/paste/util/ip4.py
@@ -260,14 +260,14 @@ if __name__ == "__main__":
# Little test script.
x = IP4Range("172.22.162.250/24")
y = IP4Range("172.22.162.250","172.22.163.250","172.22.163.253<->255")
- print x
+ print(x)
for val in x.itermasks():
- print val
+ print(val)
for val in y.itermasks():
- print val
+ print(val)
for val in (x|y).itermasks():
- print val
+ print(val)
for val in (x^y).iterranges():
- print val
+ print(val)
for val in x:
- print val
+ print(val)