[blivet][master][PATCH] Replace print statements with print function calls
Martin Kolman
mkolman at redhat.com
Tue May 20 17:05:32 UTC 2014
The print statement has been dropped in Python 3 and the print function
works in both Python 2 and Python 3. So there is really no reason to not
just use the print function and make Blivet a bit more Python 3
friendly.
Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
blivet/tsort.py | 6 +++---
doc/intro.rst | 2 +-
examples/common.py | 4 ++--
scripts/makebumpver | 40 ++++++++++++++++++++--------------------
scripts/pylintcodediff | 4 ++--
5 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/blivet/tsort.py b/blivet/tsort.py
index 4c02e14..183331d 100644
--- a/blivet/tsort.py
+++ b/blivet/tsort.py
@@ -93,11 +93,11 @@ def main():
items = [5, 2, 3, 4, 1]
edges = [(1, 2), (2, 4), (4, 5), (3, 2)]
- print items
- print edges
+ print(items)
+ print(edges)
graph = create_graph(items, edges)
- print tsort(graph)
+ print(tsort(graph))
if __name__ == "__main__":
main()
diff --git a/doc/intro.rst b/doc/intro.rst
index 2f7dc5a..3aefa7d 100644
--- a/doc/intro.rst
+++ b/doc/intro.rst
@@ -75,7 +75,7 @@ Next, scan the system's storage configuration and store it in the tree::
Now, you can do some simple things like listing the devices::
for device in b.devices:
- print device
+ print(device)
To make changes to the configuration you'll schedule actions, but
:class:`~.Blivet` provides some convenience methods to hide the details. Here's an example of removing partition '/dev/sda3'::
diff --git a/examples/common.py b/examples/common.py
index 90c735f..110026f 100644
--- a/examples/common.py
+++ b/examples/common.py
@@ -1,6 +1,6 @@
def print_devices(b):
for device in sorted(b.devices, key=lambda d: len(d.ancestors)):
- print device # this is a blivet.devices.StorageDevice instance
+ print(device) # this is a blivet.devices.StorageDevice instance
- print
+ print()
diff --git a/scripts/makebumpver b/scripts/makebumpver
index b5cb5dd..da0e060 100755
--- a/scripts/makebumpver
+++ b/scripts/makebumpver
@@ -167,47 +167,47 @@ class MakeBumpVer:
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.product.startswith('Red Hat Enterprise Linux'):
return True
else:
- print "*** Bug %s is not a RHEL bug." % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s is not a RHEL bug." % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugInCorrectState(self, bug, commit, summary):
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.bug_status in ['MODIFIED', 'ON_QA']:
return True
else:
- print "*** Bug %s is not in MODIFIED or ON_QA." % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s is not in MODIFIED or ON_QA." % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugFixedInVersion(self, bug, commit, summary, fixedIn):
bzentry = self._queryBug(bug)
if not bzentry:
- print "*** Bugzilla query for %s failed.\n" % bug
+ print("*** Bugzilla query for %s failed.\n" % bug)
return False
if bzentry.fixed_in == fixedIn:
return True
else:
- print "*** Bug %s does not have correct Fixed In Version." % bug
- print "*** Found: %s" % bzentry.fixed_in
- print "*** Expected: %s" % fixedIn
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s does not have correct Fixed In Version." % bug)
+ print("*** Found: %s" % bzentry.fixed_in)
+ print("*** Expected: %s" % fixedIn)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _isRHELBugAcked(self, bug, commit, summary):
@@ -222,9 +222,9 @@ class MakeBumpVer:
if re.match(ack_pattern, f['name']) and f['status'] == '+':
return True
- print "*** Bug %s does not have ACK" % bug
- print "*** Commit: %s" % commit
- print "*** %s\n" % summary
+ print("*** Bug %s does not have ACK" % bug)
+ print("*** Commit: %s" % commit)
+ print("*** %s\n" % summary)
return False
def _rpmLog(self, fixedIn):
@@ -347,12 +347,12 @@ class MakeBumpVer:
bad = True
elif valid and action == 'Related' and \
self._isRHELBugAcked(ckbug, commit, summary):
- print "*** Bug %s Related commit %s is allowed\n" % (bug, commit)
+ print("*** Bug %s Related commit %s is allowed\n" % (bug, commit))
# Related bugs only need to be valid and have an ack
bad = False
if len(rhbz) == 0:
- print "*** No bugs referenced in commit %s\n" % commit
+ print("*** No bugs referenced in commit %s\n" % commit)
bad = True
rpm_log.append((summary.strip(), list(rhbz)))
@@ -374,7 +374,7 @@ class MakeBumpVer:
if l.find(search) > -1:
break
else:
- print "!!! Failed to replace '%s' with '%s'" % (search, replace)
+ print("!!! Failed to replace '%s' with '%s'" % (search, replace))
sys.exit(1)
lines[i] = re.sub(search, replace, lines[i]) # pylint: disable=undefined-loop-variable
diff --git a/scripts/pylintcodediff b/scripts/pylintcodediff
index 705b014..4e30453 100755
--- a/scripts/pylintcodediff
+++ b/scripts/pylintcodediff
@@ -19,7 +19,7 @@
#
# Author: Anne Mulhern <amulhern at redhat.com>
-
+from __future__ import print_function
import argparse
import os
import subprocess
@@ -163,7 +163,7 @@ def main():
reset(commit)
diff_quality(pylint_log)
except RuntimeError as e:
- print >> sys.stderr, "Couldn't complete testing, trying to clean up: %s." % e
+ print("Couldn't complete testing, trying to clean up: %s." % e, file=sys.stderr)
try:
checkout_branch(current_branch, force=True)
--
1.9.0
More information about the anaconda-patches
mailing list