Issue #2974 - Part 1: Adapt all print statements.

2to3 . --fix print -wn
Essentially, print is a function instead of statement.
Ref:
PEP 3105
https://peps.python.org/pep-3105/
This commit is contained in:
Jeremy Andrews committed 2026-03-04 03:48:01 -06:00
1 parent 5b449bc031
commit e11fc9b4cf
442 files changed
+1875 -1889

No files matched your search

+2 -2
View File
@@ -302,7 +302,7 @@ if __name__ == "__main__":
import time
def test_overhead():
print "sender", "receiver", "+bytes", "+enctime", "+dectime"
print("sender", "receiver", "+bytes", "+enctime", "+dectime")
for s in [192, 224, 256, 384, 521]:
sender = Key.generate(s)
for r in [192, 224, 256, 384, 521]:
@@ -313,7 +313,7 @@ if __name__ == "__main__":
t = time.time()
receiver.auth_decrypt(e, sender)
t2 = time.time() - t
print s, r, len(e), t1, t2
print(s, r, len(e), t1, t2)
+4 -4
View File
@@ -36,11 +36,11 @@ def test_verification_perf(n = 100):
return results
def print_dict(title, d):
print title
print '-' * len(title)
print(title)
print('-' * len(title))
for k, v in d.items():
print k, '\t', v
print
print(k, '\t', v)
print()
n = 100
print_dict("Key generation", test_generation_perf(n))
+1 -1
View File
@@ -183,7 +183,7 @@ class ObjectGraph(object):
Print a debug message with the given level
"""
if s and level <= self.debug:
print ("%s%s %s" % (" " * self.indent, s, ' '.join(map(repr, args))))
print(("%s%s %s" % (" " * self.indent, s, ' '.join(map(repr, args)))))
def msgin(self, level, s, *args):
"""
+6 -6
View File
@@ -611,7 +611,7 @@ else:
fullname = os.path.join(toplevel, fn)
relname = os.path.relpath(fullname, 'doc/_build/html')
print ("%s -> %s"%(fullname, relname))
print(("%s -> %s"%(fullname, relname)))
zf.write(fullname, relname)
@@ -692,9 +692,9 @@ else:
self.announce('Upload failed (%s): %s' % (r.status, r.reason),
log.ERROR)
print ('-'*75)
print (r.read())
print ('-'*75)
print(('-'*75))
print((r.read()))
print(('-'*75))
def recursiveGlob(root, pathPattern):
@@ -728,7 +728,7 @@ def importExternalTestCases(unittest,
try:
module = __import__(modName)
except ImportError:
print("SKIP %s: %s"%(modName, sys.exc_info()[1]))
print(("SKIP %s: %s"%(modName, sys.exc_info()[1])))
continue
if '.' in modName:
@@ -843,7 +843,7 @@ class test (Command):
xpass=len(getattr(result, 'expectedSuccesses', [])),
skip=len(getattr(result, 'skipped', [])),
)
print("SUMMARY: %s"%(summary,))
print(("SUMMARY: %s"%(summary,)))
finally:
self.remove_from_sys_path()
@@ -66,7 +66,7 @@ data in a json useful for Exhibit
logging.getLogger().setLevel(logging.WARNING -
(options.v - options.q)*10)
observer = self.handle(args, options)
print observer.serialize(type=options.data).encode('utf-8', 'replace')
print(observer.serialize(type=options.data).encode('utf-8', 'replace'))
def handle(self, args, options):
"""Subclasses need to implement this method for the actual
@@ -110,7 +110,7 @@ Be careful to specify the right merge directory when using this option."""),
observer = compareApp(app, merge_stage=options.merge,
clobber=options.clobber)
except (OSError, IOError), exc:
print "FAIL: " + str(exc)
print("FAIL: " + str(exc))
self.parser.exit(2)
return observer
@@ -391,7 +391,7 @@ class ContentComparer:
os.makedirs(outdir)
if not p.canMerge:
shutil.copyfile(ref_file.fullpath, outfile)
print "copied reference to " + outfile
print("copied reference to " + outfile)
return
if skips:
# skips come in ordered by key name, we need them in file order
@@ -412,7 +412,7 @@ class ContentComparer:
else:
shutil.copyfile(l10n_file.fullpath, outfile)
f = codecs.open(outfile, 'ab', p.encoding)
print "adding to " + outfile
print("adding to " + outfile)
def ensureNewline(s):
if not s.endswith('\n'):
@@ -615,7 +615,7 @@ def compareApp(app, other_observer=None, merge_stage=None, clobber=False):
clobberdir = os.path.join(locale_merge, module)
if os.path.exists(clobberdir):
shutil.rmtree(clobberdir)
print "clobbered " + clobberdir
print("clobbered " + clobberdir)
dir_comp.compareWith(localization)
return comparer.observer
+1 -1
View File
@@ -146,7 +146,7 @@ class ExecutorMixin:
self.executor.shutdown(wait=True)
dt = time.time() - self.t1
if test_support.verbose:
print("%.2fs" % dt)
print(("%.2fs" % dt))
self.assertLess(dt, 60, "synchronization issue: test lasted too long")
def _prime_executor(self):
+1 -1
View File
@@ -8,7 +8,7 @@ class JsTests(unittest.TestCase):
def assertEqual(self, thing1, thing2):
if thing1 != thing2:
print(repr(thing1), repr(thing2))
print((repr(thing1), repr(thing2)))
raise AssertionError
return True
+10 -10
View File
@@ -43,28 +43,28 @@ def prefcnt(debugger, command, result, dict):
frame = thread.GetSelectedFrame()
obj = frame.EvaluateExpression(command)
if obj.GetError().Fail():
print "could not evaluate expression"
print("could not evaluate expression")
return
obj = utils.dereference(obj)
field = obj.GetChildMemberWithName("mRefCnt")
if field.GetError().Fail():
field = obj.GetChildMemberWithName("refCnt")
if field.GetError().Fail():
print "not a refcounted object"
print("not a refcounted object")
return
refcnt_type = field.GetType().GetCanonicalType().GetName()
if refcnt_type == "nsAutoRefCnt":
print field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
print(field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0))
elif refcnt_type == "nsCycleCollectingAutoRefCnt":
print field.GetChildMemberWithName("mRefCntAndFlags").GetValueAsUnsigned(0) >> 2
print(field.GetChildMemberWithName("mRefCntAndFlags").GetValueAsUnsigned(0) >> 2)
elif refcnt_type == "mozilla::ThreadSafeAutoRefCnt":
print field.GetChildMemberWithName("mValue").GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
print(field.GetChildMemberWithName("mValue").GetChildMemberWithName("mValue").GetValueAsUnsigned(0))
elif refcnt_type == "int": # non-atomic mozilla::RefCounted object
print field.GetValueAsUnsigned(0)
print(field.GetValueAsUnsigned(0))
elif refcnt_type == "mozilla::Atomic<int>": # atomic mozilla::RefCounted object
print field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0)
print(field.GetChildMemberWithName("mValue").GetValueAsUnsigned(0))
else:
print "unknown mRefCnt type " + refcnt_type
print("unknown mRefCnt type " + refcnt_type)
# Used to work around http://llvm.org/bugs/show_bug.cgi?id=22211
def callfunc(debugger, command, result, dict):
@@ -72,7 +72,7 @@ def callfunc(debugger, command, result, dict):
The function is assumed to return void."""
if '(' not in command:
print 'Usage: callfunc your_function(args)'
print('Usage: callfunc your_function(args)')
return
command_parts = command.split('(')
@@ -82,7 +82,7 @@ def callfunc(debugger, command, result, dict):
target = debugger.GetSelectedTarget()
symbols = target.FindFunctions(funcname).symbols
if not symbols:
print 'Could not find a function symbol for a function called "%s"' % funcname
print('Could not find a function symbol for a function called "%s"' % funcname)
return
sym = symbols[0]
+1 -1
View File
@@ -78,7 +78,7 @@ class MachRegistrar(object):
fail_conditions.append(c)
if fail_conditions:
print(self._condition_failed_message(handler.name, fail_conditions))
print((self._condition_failed_message(handler.name, fail_conditions)))
return 1
fn = getattr(instance, handler.method)
+2 -2
View File
@@ -9,8 +9,8 @@ from macholib.util import strip_files
def standaloneApp(path):
if not (os.path.isdir(path) and os.path.exists(
os.path.join(path, 'Contents'))):
print('%s: %s does not look like an app bundle'
% (sys.argv[0], path))
print(('%s: %s does not look like an app bundle'
% (sys.argv[0], path)))
sys.exit(1)
files = MachOStandalone(path).run()
strip_files(files)
@@ -14,7 +14,7 @@ class Builder (object):
getattr(self, nm)()
def build_executable(self):
print "Building plain executable"
print("Building plain executable")
pass
+6 -6
View File
@@ -611,7 +611,7 @@ else:
fullname = os.path.join(toplevel, fn)
relname = os.path.relpath(fullname, 'doc/_build/html')
print ("%s -> %s"%(fullname, relname))
print(("%s -> %s"%(fullname, relname)))
zf.write(fullname, relname)
@@ -692,9 +692,9 @@ else:
self.announce('Upload failed (%s): %s' % (r.status, r.reason),
log.ERROR)
print ('-'*75)
print (r.read())
print ('-'*75)
print(('-'*75))
print((r.read()))
print(('-'*75))
def recursiveGlob(root, pathPattern):
@@ -728,7 +728,7 @@ def importExternalTestCases(unittest,
try:
module = __import__(modName)
except ImportError:
print("SKIP %s: %s"%(modName, sys.exc_info()[1]))
print(("SKIP %s: %s"%(modName, sys.exc_info()[1])))
continue
if '.' in modName:
@@ -843,7 +843,7 @@ class test (Command):
xpass=len(getattr(result, 'expectedSuccesses', [])),
skip=len(getattr(result, 'skipped', [])),
)
print("SUMMARY: %s"%(summary,))
print(("SUMMARY: %s"%(summary,)))
finally:
self.remove_from_sys_path()
+1 -1
View File
@@ -55,7 +55,7 @@ def InvokeClWithDependencyGeneration(cmdline):
break
if target is None:
print >>sys.stderr, "No target set"
print("No target set", file=sys.stderr)
return 1
# Assume the source file is the last argument
+1 -1
View File
@@ -13,4 +13,4 @@ sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from shellutil import quote
for key, value in os.environ.items():
print('%s=%s' % (key, quote(value)))
print(('%s=%s' % (key, quote(value))))
@@ -18,4 +18,4 @@ if locale in searchinfo["locales"]:
else:
engines = searchinfo["default"]["visibleDefaultEngines"]
print '\n'.join(engines)
print('\n'.join(engines))
+3 -3
View File
@@ -40,7 +40,7 @@ def verifyDirectory(initests, directory):
break
if not found:
print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini'))
print("TEST-UNEXPECTED-FAIL | xpccheck | test %s is missing from test manifest %s!" % (name, os.path.join(directory, 'xpcshell.ini')), file=sys.stderr)
sys.exit(1)
def verifyIniFile(initests, directory):
@@ -60,12 +60,12 @@ def verifyIniFile(initests, directory):
break
if not found:
print >>sys.stderr, "TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory)
print("TEST-UNEXPECTED-FAIL | xpccheck | found %s in xpcshell.ini and not in directory '%s'" % (name, directory), file=sys.stderr)
sys.exit(1)
def main(argv):
if len(argv) < 2:
print >>sys.stderr, "Usage: xpccheck.py <topsrcdir> <directory> [<directory> ...]"
print("Usage: xpccheck.py <topsrcdir> <directory> [<directory> ...]", file=sys.stderr)
sys.exit(1)
topsrcdir = argv[0]
@@ -59,5 +59,5 @@ class Introspection(MachCommandBase):
# Drop the first flag since that is the pathname of the compiler.
flags = (shell_split(build_vars[cc]) + shell_split(build_vars[name]))[1:]
print(' '.join(shell_quote(arg)
for arg in util.sanitize_cflags(flags)))
print((' '.join(shell_quote(arg)
for arg in util.sanitize_cflags(flags))))
@@ -59,4 +59,4 @@ def main(bin, compilation_unit):
if __name__ == '__main__':
print main(*sys.argv[1:])
print(main(*sys.argv[1:]))
@@ -666,8 +666,8 @@ class BuildDriver(MozbuildObject):
"""Install test files."""
if self.is_clobber_needed():
print(INSTALL_TESTS_CLOBBER.format(
clobber_file=os.path.join(self.topobjdir, 'CLOBBER')))
print((INSTALL_TESTS_CLOBBER.format(
clobber_file=os.path.join(self.topobjdir, 'CLOBBER'))))
sys.exit(1)
if not test_objs:
+2 -2
View File
@@ -103,11 +103,11 @@ class Doctor(object):
if status == 'SKIPPED':
continue
self.results.append(result)
print('%s...\t%s\n' % (
print(('%s...\t%s\n' % (
result.get('desc', ''),
status
)
).expandtabs(40)
).expandtabs(40))
@property
def platform(self):
+1 -1
View File
@@ -93,7 +93,7 @@ class TestMozbuildObject(unittest.TestCase):
mozconfig = os.path.join(d, 'mozconfig')
with open(mozconfig, 'wt') as fh:
fh.write('mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/foo/@CONFIG_GUESS@')
print('Wrote mozconfig %s' % mozconfig)
print(('Wrote mozconfig %s' % mozconfig))
topobjdir = os.path.join(d, 'foo', guess)
os.makedirs(topobjdir)
+1 -1
View File
@@ -97,7 +97,7 @@ class ErrorCollector(object):
if self._count is None:
raise ErrorMessage(msg)
self._count += 1
print >>self.out, msg
print(msg, file=self.out)
def fatal(self, msg):
self._handle(self.FATAL, msg)
+1 -1
View File
@@ -31,7 +31,7 @@ class BaseType(object):
"""
paths = filterpaths(paths, linter, **lintargs)
if not paths:
print("{}: no files to lint in specified paths".format(linter['name']))
print(("{}: no files to lint in specified paths".format(linter['name'])))
return
if self.batch:
+4 -4
View File
@@ -39,8 +39,8 @@ def bytes2human(n):
def main():
templ = "%-17s %8s %8s %8s %5s%% %9s %s"
print(templ % ("Device", "Total", "Used", "Free", "Use ", "Type",
"Mount"))
print((templ % ("Device", "Total", "Used", "Free", "Use ", "Type",
"Mount")))
for part in psutil.disk_partitions(all=False):
if os.name == 'nt':
if 'cdrom' in part.opts or part.fstype == '':
@@ -49,14 +49,14 @@ def main():
# partition or just hang.
continue
usage = psutil.disk_usage(part.mountpoint)
print(templ % (
print((templ % (
part.device,
bytes2human(usage.total),
bytes2human(usage.used),
bytes2human(usage.free),
int(usage.percent),
part.fstype,
part.mountpoint))
part.mountpoint)))
if __name__ == '__main__':
sys.exit(main())
+5 -5
View File
@@ -20,22 +20,22 @@ def main():
virt = psutil.virtual_memory()
swap = psutil.swap_memory()
templ = "%-7s %10s %10s %10s %10s %10s %10s"
print(templ % ('', 'total', 'used', 'free', 'shared', 'buffers', 'cache'))
print(templ % (
print((templ % ('', 'total', 'used', 'free', 'shared', 'buffers', 'cache')))
print((templ % (
'Mem:',
int(virt.total / 1024),
int(virt.used / 1024),
int(virt.free / 1024),
int(getattr(virt, 'shared', 0) / 1024),
int(getattr(virt, 'buffers', 0) / 1024),
int(getattr(virt, 'cached', 0) / 1024)))
print(templ % (
int(getattr(virt, 'cached', 0) / 1024))))
print((templ % (
'Swap:', int(swap.total / 1024),
int(swap.used / 1024),
int(swap.free / 1024),
'',
'',
''))
'')))
if __name__ == '__main__':
main()
+1 -1
View File
@@ -55,7 +55,7 @@ def pprint_ntuple(nt):
value = getattr(nt, name)
if name != 'percent':
value = bytes2human(value)
print('%-10s : %7s' % (name.capitalize(), value))
print(('%-10s : %7s' % (name.capitalize(), value)))
def main():
+4 -4
View File
@@ -37,9 +37,9 @@ proto_map = {
def main():
templ = "%-5s %-30s %-30s %-13s %-6s %s"
print(templ % (
print((templ % (
"Proto", "Local address", "Remote address", "Status", "PID",
"Program name"))
"Program name")))
proc_names = {}
for p in psutil.process_iter():
try:
@@ -51,14 +51,14 @@ def main():
raddr = ""
if c.raddr:
raddr = "%s:%s" % (c.raddr)
print(templ % (
print((templ % (
proto_map[(c.family, c.type)],
laddr,
raddr or AD,
c.status,
c.pid or AD,
proc_names.get(c.pid, '?')[:15],
))
)))
if __name__ == '__main__':
main()
+6 -6
View File
@@ -39,19 +39,19 @@ def main():
if len(sys.argv) != 2:
sys.exit('usage: pmap <pid>')
p = psutil.Process(int(sys.argv[1]))
print("pid=%s, name=%s" % (p.pid, p.name()))
print(("pid=%s, name=%s" % (p.pid, p.name())))
templ = "%-16s %10s %-7s %s"
print(templ % ("Address", "RSS", "Mode", "Mapping"))
print((templ % ("Address", "RSS", "Mode", "Mapping")))
total_rss = 0
for m in p.memory_maps(grouped=False):
total_rss += m.rss
print(templ % (
print((templ % (
m.addr.split('-')[0].zfill(16),
str(m.rss / 1024) + 'K',
m.perms,
m.path))
print("-" * 33)
print(templ % ("Total", str(total_rss / 1024) + 'K', '', ''))
m.path)))
print(("-" * 33))
print((templ % ("Total", str(total_rss / 1024) + 'K', '', '')))
if __name__ == '__main__':
main()
+4 -4
View File
@@ -26,8 +26,8 @@ def main():
if os.name == 'posix':
attrs.append('uids')
attrs.append('terminal')
print(templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
"START", "TIME", "COMMAND"))
print((templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
"START", "TIME", "COMMAND")))
for p in psutil.process_iter():
try:
pinfo = p.as_dict(attrs, ad_value='')
@@ -64,7 +64,7 @@ def main():
int(pinfo['memory_info'].rss / 1024) or '?'
memp = pinfo['memory_percent'] and \
round(pinfo['memory_percent'], 1) or '?'
print(templ % (
print((templ % (
user[:10],
pinfo['pid'],
pinfo['cpu_percent'],
@@ -74,7 +74,7 @@ def main():
pinfo.get('terminal', '') or '?',
ctime,
cputime,
pinfo['name'].strip() or '?'))
pinfo['name'].strip() or '?')))
if __name__ == '__main__':
+2 -2
View File
@@ -23,11 +23,11 @@ import psutil
def main():
users = psutil.users()
for user in users:
print("%-15s %-15s %s (%s)" % (
print(("%-15s %-15s %s (%s)" % (
user.name,
user.terminal or '-',
datetime.fromtimestamp(user.started).strftime("%Y-%m-%d %H:%M"),
user.host))
user.host)))
if __name__ == '__main__':
main()
+4 -4
View File
@@ -1836,8 +1836,8 @@ def test():
if _POSIX:
attrs.append('uids')
attrs.append('terminal')
print(templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
"START", "TIME", "COMMAND"))
print((templ % ("USER", "PID", "%CPU", "%MEM", "VSZ", "RSS", "TTY",
"START", "TIME", "COMMAND")))
for p in process_iter():
try:
pinfo = p.as_dict(attrs, ad_value='')
@@ -1866,7 +1866,7 @@ def test():
int(pinfo['memory_info'].rss / 1024) or '?'
memp = pinfo['memory_percent'] and \
round(pinfo['memory_percent'], 1) or '?'
print(templ % (
print((templ % (
user[:10],
pinfo['pid'],
pinfo['cpu_percent'],
@@ -1876,7 +1876,7 @@ def test():
pinfo.get('terminal', '') or '?',
ctime,
cputime,
pinfo['name'].strip() or '?'))
pinfo['name'].strip() or '?')))
del memoize, division
+1 -1
View File
@@ -56,7 +56,7 @@ class SvnCommandPath(svncommon.SvnPathBase):
# fixing the locale because we can't otherwise parse
string = " ".join(l)
if DEBUG:
print("execing %s" % string)
print(("execing %s" % string))
out = self._svncmdexecauth(string)
return out
+3 -3
View File
@@ -9,8 +9,8 @@ import sys
if len(sys.argv) == 2 and sys.argv[1] == '-d':
debug.setLogger(debug.Debug('all'))
elif len(sys.argv) != 1:
print("""Usage:
$ cat cmp.pem | %s [-d]""" % sys.argv[0])
print(("""Usage:
$ cat cmp.pem | %s [-d]""" % sys.argv[0]))
sys.exit(-1)
pkiMessage = rfc4210.PKIMessage()
@@ -21,7 +21,7 @@ if not substrate:
pkiMsg, rest = decoder.decode(substrate, asn1Spec=pkiMessage)
print(pkiMsg.prettyPrint())
print((pkiMsg.prettyPrint()))
assert encoder.encode(pkiMsg, defMode=False) == substrate or \
encoder.encode(pkiMsg, defMode=True) == substrate, \
+4 -4
View File
@@ -9,8 +9,8 @@ from pyasn1.codec.der import encoder, decoder
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat crl.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat crl.pem | %s""" % sys.argv[0]))
sys.exit(-1)
asn1Spec = rfc2459.CertificateList()
@@ -27,7 +27,7 @@ while 1:
if rest: substrate = substrate[:-len(rest)]
print(key.prettyPrint())
print((key.prettyPrint()))
assert encoder.encode(key, defMode=False) == substrate or \
encoder.encode(key, defMode=True) == substrate, \
@@ -35,4 +35,4 @@ while 1:
cnt = cnt + 1
print('*** %s CRL(s) re/serialized' % cnt)
print(('*** %s CRL(s) re/serialized' % cnt))
+3 -3
View File
@@ -6,8 +6,8 @@ from pyasn1_modules import rfc2511, pem
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat crmf.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat crmf.pem | %s""" % sys.argv[0]))
sys.exit(-1)
certReq = rfc2511.CertReqMessages()
@@ -18,7 +18,7 @@ if not substrate:
cr, rest = decoder.decode(substrate, asn1Spec=certReq)
print(cr.prettyPrint())
print((cr.prettyPrint()))
assert encoder.encode(cr, defMode=False) == substrate or \
encoder.encode(cr, defMode=True) == substrate, \
+4 -4
View File
@@ -97,8 +97,8 @@ def parseOcspResponse(ocspResponse):
)
if len(sys.argv) != 2:
print("""Usage:
$ cat CACertificate.pem userCertificate.pem | %s <ocsp-responder-url>""" % sys.argv[0])
print(("""Usage:
$ cat CACertificate.pem userCertificate.pem | %s <ocsp-responder-url>""" % sys.argv[0]))
sys.exit(-1)
else:
ocspUrl = sys.argv[1]
@@ -138,8 +138,8 @@ ocspRsp, _ = decoder.decode(httpRsp, asn1Spec=rfc2560.OCSPResponse())
producedAt, certId, certStatus, thisUpdate = parseOcspResponse(ocspRsp)
print('Certificate ID %s is %s at %s till %s\n' % (
print(('Certificate ID %s is %s at %s till %s\n' % (
certId.getComponentByName('serialNumber'),
certStatus,
producedAt,
thisUpdate))
thisUpdate)))
+3 -3
View File
@@ -8,8 +8,8 @@ from pyasn1_modules import rfc2560, pem
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat ocsp-request.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat ocsp-request.pem | %s""" % sys.argv[0]))
sys.exit(-1)
ocspReq = rfc2560.OCSPRequest()
@@ -20,7 +20,7 @@ if not substrate:
cr, rest = decoder.decode(substrate, asn1Spec=ocspReq)
print(cr.prettyPrint())
print((cr.prettyPrint()))
assert encoder.encode(cr, defMode=False) == substrate or \
encoder.encode(cr, defMode=True) == substrate, \
+3 -3
View File
@@ -8,8 +8,8 @@ from pyasn1_modules import rfc2560, pem
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat ocsp-response.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat ocsp-response.pem | %s""" % sys.argv[0]))
sys.exit(-1)
ocspReq = rfc2560.OCSPResponse()
@@ -20,7 +20,7 @@ if not substrate:
cr, rest = decoder.decode(substrate, asn1Spec=ocspReq)
print(cr.prettyPrint())
print((cr.prettyPrint()))
assert encoder.encode(cr, defMode=False) == substrate or \
encoder.encode(cr, defMode=True) == substrate, \
+4 -4
View File
@@ -98,8 +98,8 @@ def parseOcspRequest(ocspRequest):
)
if len(sys.argv) != 2:
print("""Usage:
$ cat CACertificate.pem userCertificate.pem | %s <ocsp-responder-url>""" % sys.argv[0])
print(("""Usage:
$ cat CACertificate.pem userCertificate.pem | %s <ocsp-responder-url>""" % sys.argv[0]))
sys.exit(-1)
else:
ocspUrl = sys.argv[1]
@@ -135,9 +135,9 @@ ocspRsp, _ = decoder.decode(httpRsp, asn1Spec=rfc2560.OCSPResponse())
producedAt, certId, certStatus, thisUpdate = parseOcspResponse(ocspRsp)
print('Certificate ID %s is %s at %s till %s\n' % (
print(('Certificate ID %s is %s at %s till %s\n' % (
certId.getComponentByName('serialNumber'),
certStatus,
producedAt,
thisUpdate
))
)))
+4 -4
View File
@@ -8,8 +8,8 @@ from pyasn1_modules import rfc2314, pem
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat certificateRequest.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat certificateRequest.pem | %s""" % sys.argv[0]))
sys.exit(-1)
certType = rfc2314.CertificationRequest()
@@ -28,7 +28,7 @@ while 1:
if rest: substrate = substrate[:-len(rest)]
print(cert.prettyPrint())
print((cert.prettyPrint()))
assert encoder.encode(cert, defMode=False) == substrate or \
encoder.encode(cert, defMode=True) == substrate, \
@@ -36,4 +36,4 @@ while 1:
certCnt = certCnt + 1
print('*** %s PEM certificate request(s) de/serialized' % certCnt)
print(('*** %s PEM certificate request(s) de/serialized' % certCnt))
+4 -4
View File
@@ -9,8 +9,8 @@ from pyasn1.codec.der import encoder, decoder
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat rsakey.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat rsakey.pem | %s""" % sys.argv[0]))
sys.exit(-1)
cnt = 0
@@ -31,7 +31,7 @@ while 1:
if rest: substrate = substrate[:-len(rest)]
print(key.prettyPrint())
print((key.prettyPrint()))
assert encoder.encode(key, defMode=False) == substrate or \
encoder.encode(key, defMode=True) == substrate, \
@@ -39,4 +39,4 @@ while 1:
cnt = cnt + 1
print('*** %s key(s) re/serialized' % cnt)
print(('*** %s key(s) re/serialized' % cnt))
+4 -4
View File
@@ -8,8 +8,8 @@ from pyasn1.codec.der import encoder, decoder
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat pkcs7Certificate.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat pkcs7Certificate.pem | %s""" % sys.argv[0]))
sys.exit(-1)
idx, substrate = pem.readPemBlocksFromFile(
@@ -22,7 +22,7 @@ contentInfo, rest = decoder.decode(substrate, asn1Spec=rfc2315.ContentInfo())
if rest: substrate = substrate[:-len(rest)]
print(contentInfo.prettyPrint())
print((contentInfo.prettyPrint()))
assert encoder.encode(contentInfo, defMode=False) == substrate or \
encoder.encode(contentInfo, defMode=True) == substrate, \
@@ -44,4 +44,4 @@ content, _ = decoder.decode(
asn1Spec=contentInfoMap[contentType]
)
print(content.prettyPrint())
print((content.prettyPrint()))
+4 -4
View File
@@ -8,8 +8,8 @@ from pyasn1_modules import rfc5208, pem
import sys
if len(sys.argv) != 1:
print("""Usage:
$ cat pkcs8key.pem | %s""" % sys.argv[0])
print(("""Usage:
$ cat pkcs8key.pem | %s""" % sys.argv[0]))
sys.exit(-1)
cnt = 0
@@ -30,7 +30,7 @@ while 1:
if rest: substrate = substrate[:-len(rest)]
print(key.prettyPrint())
print((key.prettyPrint()))
assert encoder.encode(key, defMode=False) == substrate or \
encoder.encode(key, defMode=True) == substrate, \
@@ -38,4 +38,4 @@ while 1:
cnt = cnt + 1
print('*** %s PKCS#8 key(s) de/serialized' % cnt)
print(('*** %s PKCS#8 key(s) de/serialized' % cnt))
+4 -4
View File
@@ -7,8 +7,8 @@ from pyasn1_modules import rfc1157
import sys, socket
if len(sys.argv) != 4:
print("""Usage:
$ %s <community> <host> <OID>""" % sys.argv[0])
print(("""Usage:
$ %s <community> <host> <OID>""" % sys.argv[0]))
sys.exit(-1)
msg = rfc1157.Message()
@@ -25,7 +25,7 @@ vb = vbl.setComponentByPosition(0).getComponentByPosition(0)
vb.setComponentByPosition(0, sys.argv[3])
v = vb.setComponentByPosition(1).getComponentByPosition(1).setComponentByPosition(0).getComponentByPosition(0).setComponentByPosition(3).getComponentByPosition(3)
print('sending: %s' % msg.prettyPrint())
print(('sending: %s' % msg.prettyPrint()))
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(encoder.encode(msg), (sys.argv[2], 161))
@@ -34,4 +34,4 @@ substrate, _ = sock.recvfrom(2048)
rMsg, _ = decoder.decode(substrate, asn1Spec=msg)
print('received: %s' % rMsg.prettyPrint())
print(('received: %s' % rMsg.prettyPrint()))
+4 -4
View File
@@ -8,9 +8,9 @@ from pyasn1_modules import rfc2459, pem
import sys
if len(sys.argv) != 1:
print("""Usage:
print(("""Usage:
$ cat CACertificate.pem | %s
$ cat userCertificate.pem | %s""" % (sys.argv[0], sys.argv[0]))
$ cat userCertificate.pem | %s""" % (sys.argv[0], sys.argv[0])))
sys.exit(-1)
certType = rfc2459.Certificate()
@@ -29,7 +29,7 @@ while 1:
if rest: substrate = substrate[:-len(rest)]
print(cert.prettyPrint())
print((cert.prettyPrint()))
assert encoder.encode(cert, defMode=False) == substrate or \
encoder.encode(cert, defMode=True) == substrate, \
@@ -37,4 +37,4 @@ while 1:
certCnt = certCnt + 1
print('*** %s PEM cert(s) de/serialized' % certCnt)
print(('*** %s PEM cert(s) de/serialized' % certCnt))
+1 -1
View File
@@ -88,7 +88,7 @@ def main(sys_argv=sys.argv):
context = json.loads(context)
rendered = renderer.render(template, context)
print rendered
print(rendered)
if __name__=='__main__':
+6 -6
View File
@@ -170,7 +170,7 @@ def write(u, path):
Write a unicode string to a file (as utf-8).
"""
print("writing to: %s" % path)
print(("writing to: %s" % path))
# This function implementation was chosen to be compatible across Python 2/3.
f = open(path, "wb")
try:
@@ -222,8 +222,8 @@ def convert_md_to_rst(md_path, rst_temp_path):
"""
# Pandoc uses the UTF-8 character encoding for both input and output.
command = "pandoc --write=rst --output=%s %s" % (rst_temp_path, md_path)
print("converting with pandoc: %s to %s\n-->%s" % (md_path, rst_temp_path,
command))
print(("converting with pandoc: %s to %s\n-->%s" % (md_path, rst_temp_path,
command)))
if os.path.exists(rst_temp_path):
os.remove(rst_temp_path)
@@ -290,15 +290,15 @@ def publish():
long_description = make_long_description()
if long_description != read(RST_DESCRIPTION_PATH):
print("""\
print(("""\
Description file not up-to-date: %s
Run the following command and commit the changes--
python setup.py %s
""" % (RST_DESCRIPTION_PATH, PREP_COMMAND))
""" % (RST_DESCRIPTION_PATH, PREP_COMMAND)))
sys.exit()
print("Description up-to-date: %s" % RST_DESCRIPTION_PATH)
print(("Description up-to-date: %s" % RST_DESCRIPTION_PATH))
answer = raw_input("Are you sure you want to publish to PyPI (yes/no)?")
+1 -1
View File
@@ -920,7 +920,7 @@ class Testdir:
for line in lines:
py.builtin.print_(line, file=fp)
except UnicodeEncodeError:
print("couldn't print to %s because of encoding" % (fp,))
print(("couldn't print to %s because of encoding" % (fp,)))
def _getpytestargs(self):
# we cannot use "(sys.executable,script)"
+3 -3
View File
@@ -51,7 +51,7 @@ def _main():
for path in args.dir:
if not os.path.isdir(path):
print('error: not a dir: {0}'.format(path))
print(('error: not a dir: {0}'.format(path)))
return 2
for top, dirnames, fnames in os.walk(path):
for fname in fnames:
@@ -90,10 +90,10 @@ def _main():
succeeded.append(fname)
for f, parsed, bench, e in failed:
print('failed: {}\n{}\n{}'.format(f, json.dumps(parsed, indent=4), json.dumps(bench, indent=4)))
print(('failed: {}\n{}\n{}'.format(f, json.dumps(parsed, indent=4), json.dumps(bench, indent=4))))
if e:
traceback.print_exception(*e)
print('succeeded: {0}'.format(len(succeeded)))
print(('succeeded: {0}'.format(len(succeeded))))
return 1 if failed or not succeeded else 0
if __name__ == '__main__':
+1 -1
View File
@@ -22,4 +22,4 @@ except ImportError:
return os.path.join(os.path.dirname(__file__), 'cacert.pem')
if __name__ == '__main__':
print(where())
print((where()))
+2 -2
View File
@@ -20,8 +20,8 @@ def run_speed_test(bitsize):
duration = end - start
dur_per_call = duration / iterations
print '%5i bit: %9.3f sec. (%i iterations over %.1f seconds)' % (bitsize,
dur_per_call, iterations, duration)
print('%5i bit: %9.3f sec. (%i iterations over %.1f seconds)' % (bitsize,
dur_per_call, iterations, duration))
for bitsize in (128, 256, 384, 512, 1024, 2048, 3072, 4096):
run_speed_test(bitsize)
+1 -1
View File
@@ -605,7 +605,7 @@ if __name__ == '__main__':
break
if (count and count % 10 == 0) or count == 1:
print('%i times' % count)
print(('%i times' % count))
except KeyboardInterrupt:
print('Aborted')
else:
+1 -1
View File
@@ -386,6 +386,6 @@ if __name__ == '__main__':
break
if count and count % 100 == 0:
print('%i times' % count)
print(('%i times' % count))
print('Doctests done')
+1 -1
View File
@@ -161,6 +161,6 @@ if __name__ == '__main__':
break
if count and count % 100 == 0:
print('%i times' % count)
print(('%i times' % count))
print('Doctests done')
+5 -5
View File
@@ -12,13 +12,13 @@ class IntegerTest(unittest2.TestCase):
def test_enc_dec(self):
message = 42
print("\tMessage: %d" % message)
print(("\tMessage: %d" % message))
encrypted = rsa.core.encrypt_int(message, self.pub.e, self.pub.n)
print("\tEncrypted: %d" % encrypted)
print(("\tEncrypted: %d" % encrypted))
decrypted = rsa.core.decrypt_int(encrypted, self.priv.d, self.pub.n)
print("\tDecrypted: %d" % decrypted)
print(("\tDecrypted: %d" % decrypted))
self.assertEqual(message, decrypted)
@@ -27,10 +27,10 @@ class IntegerTest(unittest2.TestCase):
message = 42
signed = rsa.core.encrypt_int(message,self.priv.d, self.pub.n)
print("\tSigned: %d" % signed)
print(("\tSigned: %d" % signed))
verified = rsa.core.decrypt_int(signed, self.pub.e,self.pub.n)
print("\tVerified: %d" % verified)
print(("\tVerified: %d" % verified))
self.assertEqual(message, verified)
+5 -5
View File
@@ -15,13 +15,13 @@ class BinaryTest(unittest2.TestCase):
def test_enc_dec(self):
message = struct.pack('>IIII', 0, 0, 0, 1)
print("\tMessage: %r" % message)
print(("\tMessage: %r" % message))
encrypted = pkcs1.encrypt(message, self.pub)
print("\tEncrypted: %r" % encrypted)
print(("\tEncrypted: %r" % encrypted))
decrypted = pkcs1.decrypt(encrypted, self.priv)
print("\tDecrypted: %r" % decrypted)
print(("\tDecrypted: %r" % decrypted))
self.assertEqual(message, decrypted)
@@ -59,10 +59,10 @@ class SignatureTest(unittest2.TestCase):
'''Test happy flow of sign and verify'''
message = b('je moeder')
print("\tMessage: %r" % message)
print(("\tMessage: %r" % message))
signature = pkcs1.sign(message, self.priv, 'SHA-256')
print("\tSignature: %r" % signature)
print(("\tSignature: %r" % signature))
self.assertTrue(pkcs1.verify(message, signature, self.pub))
+3 -3
View File
@@ -16,13 +16,13 @@ class StringTest(unittest2.TestCase):
def test_enc_dec(self):
message = unicode_string.encode('utf-8')
print("\tMessage: %s" % message)
print(("\tMessage: %s" % message))
encrypted = rsa.encrypt(message, self.pub)
print("\tEncrypted: %s" % encrypted)
print(("\tEncrypted: %s" % encrypted))
decrypted = rsa.decrypt(encrypted, self.priv)
print("\tDecrypted: %s" % decrypted)
print(("\tDecrypted: %s" % decrypted))
self.assertEqual(message, decrypted)
+7 -7
View File
@@ -458,7 +458,7 @@ class _Printer(object):
while 1:
try:
for i in range(lineno, lineno + self.MAXLINES):
print(self.__lines[i])
print((self.__lines[i]))
except IndexError:
break
else:
@@ -727,16 +727,16 @@ def _script():
if not args:
print("sys.path = [")
for dir in sys.path:
print(" %r," % (dir,))
print((" %r," % (dir,)))
print("]")
def exists(path):
if os.path.isdir(path):
return "exists"
else:
return "doesn't exist"
print("USER_BASE: %r (%s)" % (USER_BASE, exists(USER_BASE)))
print("USER_SITE: %r (%s)" % (USER_SITE, exists(USER_BASE)))
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
print(("USER_BASE: %r (%s)" % (USER_BASE, exists(USER_BASE))))
print(("USER_SITE: %r (%s)" % (USER_SITE, exists(USER_BASE))))
print(("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE))
sys.exit(0)
buffer = []
@@ -746,7 +746,7 @@ def _script():
buffer.append(USER_SITE)
if buffer:
print(os.pathsep.join(buffer))
print((os.pathsep.join(buffer)))
if ENABLE_USER_SITE:
sys.exit(0)
elif ENABLE_USER_SITE is False:
@@ -757,7 +757,7 @@ def _script():
sys.exit(3)
else:
import textwrap
print(textwrap.dedent(help % (sys.argv[0], os.pathsep)))
print((textwrap.dedent(help % (sys.argv[0], os.pathsep))))
sys.exit(10)
if __name__ == '__main__':
+5 -5
View File
@@ -40,7 +40,7 @@ __version__ = "15.0.1"
virtualenv_version = __version__ # legacy
if sys.version_info < (2, 6):
print('ERROR: %s' % sys.exc_info()[1])
print(('ERROR: %s' % sys.exc_info()[1]))
print('ERROR: this script requires Python 2.6 or greater.')
sys.exit(101)
@@ -479,7 +479,7 @@ class ConfigOptionParser(optparse.OptionParser):
val = option.convert_value(key, val)
except optparse.OptionValueError:
e = sys.exc_info()[1]
print("An error occurred during configuration: %s" % e)
print(("An error occurred during configuration: %s" % e))
sys.exit(3)
defaults[option.dest] = val
return defaults
@@ -679,8 +679,8 @@ def main():
parser.print_help()
sys.exit(2)
if len(args) > 1:
print('There must be only one argument: DEST_DIR (you gave %s)' % (
' '.join(args)))
print(('There must be only one argument: DEST_DIR (you gave %s)' % (
' '.join(args))))
parser.print_help()
sys.exit(2)
@@ -979,7 +979,7 @@ def path_locations(home_dir):
u = str
ret = GetShortPathName(u(home_dir), buf, size)
if not ret:
print('Error: the path "%s" has a space in it' % home_dir)
print(('Error: the path "%s" has a space in it' % home_dir))
print('We could not determine the short pathname for it.')
print('Exiting.')
sys.exit(3)
@@ -453,7 +453,7 @@ class _Printer(object):
while 1:
try:
for i in range(lineno, lineno + self.MAXLINES):
print(self.__lines[i])
print((self.__lines[i]))
except IndexError:
break
else:
@@ -721,16 +721,16 @@ def _script():
if not args:
print("sys.path = [")
for dir in sys.path:
print(" %r," % (dir,))
print((" %r," % (dir,)))
print("]")
def exists(path):
if os.path.isdir(path):
return "exists"
else:
return "doesn't exist"
print("USER_BASE: %r (%s)" % (USER_BASE, exists(USER_BASE)))
print("USER_SITE: %r (%s)" % (USER_SITE, exists(USER_BASE)))
print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
print(("USER_BASE: %r (%s)" % (USER_BASE, exists(USER_BASE))))
print(("USER_SITE: %r (%s)" % (USER_SITE, exists(USER_BASE))))
print(("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE))
sys.exit(0)
buffer = []
@@ -740,7 +740,7 @@ def _script():
buffer.append(USER_SITE)
if buffer:
print(os.pathsep.join(buffer))
print((os.pathsep.join(buffer)))
if ENABLE_USER_SITE:
sys.exit(0)
elif ENABLE_USER_SITE is False:
@@ -751,7 +751,7 @@ def _script():
sys.exit(3)
else:
import textwrap
print(textwrap.dedent(help % (sys.argv[0], os.pathsep)))
print((textwrap.dedent(help % (sys.argv[0], os.pathsep))))
sys.exit(10)
if __name__ == '__main__':
+4 -4
View File
@@ -192,12 +192,12 @@ def _listTargets(targets):
nameWidth = max(nameWidth, len(name))
nameWidth += 2 # space btwn name and doc
format = "%%-%ds%%s" % nameWidth
print format % ("TARGET", "DESCRIPTION")
print(format % ("TARGET", "DESCRIPTION"))
for name, func in sorted(targets.items()):
doc = _first_paragraph(func.__doc__ or "", True)
if len(doc) > (width - nameWidth):
doc = doc[:(width-nameWidth-3)] + "..."
print format % (name, doc)
print(format % (name, doc))
# Recipe: first_paragraph (1.0.1) in /Users/trentm/tm/recipes/cookbook
@@ -234,7 +234,7 @@ def target_clean():
ver = _get_project_version()
dirs = ["dist", "build", "%s-%s" % (_project_name_, ver)]
for d in dirs:
print "removing '%s'" % d
print("removing '%s'" % d)
if os.path.isdir(d): _rmtree(d)
patterns = ["*.pyc", "*~", "MANIFEST",
@@ -243,7 +243,7 @@ def target_clean():
]
for pattern in patterns:
for file in glob.glob(pattern):
print "removing '%s'" % file
print("removing '%s'" % file)
os.unlink(file)
+4 -4
View File
@@ -287,10 +287,10 @@ def main(argv):
return 1
for opt, optarg in optlist:
if opt in ('-h', '--help'):
print _cmdlnUsage
print(_cmdlnUsage)
return 0
elif opt in ('-V', '--version'):
print "which %s" % __version__
print("which %s" % __version__)
return 0
elif opt in ('-a', '--all'):
all = 1
@@ -318,9 +318,9 @@ def main(argv):
nmatches = 0
for match in whichgen(arg, path=altpath, verbose=verbose, exts=exts):
if verbose:
print "%s (%s)" % match
print("%s (%s)" % match)
else:
print match
print(match)
nmatches += 1
if not all:
break