From cecd1d864fc3cf02cf50d367111e0d0e173c5dc6 Mon Sep 17 00:00:00 2001 From: Sarah Owens Date: Thu, 1 Nov 2012 22:59:27 -0700 Subject: Change print statements to work in python3 This is part of a series of changes to introduce Python3 support. Change-Id: I373be5de7141aa127d7debdbce1df39148dbec32 --- subcmds/help.py | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'subcmds/help.py') diff --git a/subcmds/help.py b/subcmds/help.py index 375d04d2..57fb3cc2 100644 --- a/subcmds/help.py +++ b/subcmds/help.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import re import sys from formatter import AbstractFormatter, DumbWriter @@ -31,10 +32,8 @@ Displays detailed usage information about a command. """ def _PrintAllCommands(self): - print 'usage: repo COMMAND [ARGS]' - print """ -The complete list of recognized repo commands are: -""" + print('usage: repo COMMAND [ARGS]') + print('The complete list of recognized repo commands are:') commandNames = self.commands.keys() commandNames.sort() @@ -49,17 +48,14 @@ The complete list of recognized repo commands are: summary = command.helpSummary.strip() except AttributeError: summary = '' - print fmt % (name, summary) - print """ -See 'repo help ' for more information on a specific command. -""" + print(fmt % (name, summary)) + print("See 'repo help ' for more information on a" + 'specific command.') def _PrintCommonCommands(self): - print 'usage: repo COMMAND [ARGS]' - print """ -The most commonly used repo commands are: -""" - commandNames = [name + print('usage: repo COMMAND [ARGS]') + print('The most commonly used repo commands are:') + commandNames = [name for name in self.commands.keys() if self.commands[name].common] commandNames.sort() @@ -75,11 +71,10 @@ The most commonly used repo commands are: summary = command.helpSummary.strip() except AttributeError: summary = '' - print fmt % (name, summary) - print """ -See 'repo help ' for more information on a specific command. -See 'repo help --all' for a complete list of recognized commands. -""" + print(fmt % (name, summary)) + print( +"See 'repo help ' for more information on a specific command.\n" +"See 'repo help --all' for a complete list of recognized commands.") def _PrintCommandHelp(self, cmd): class _Out(Coloring): @@ -162,7 +157,7 @@ See 'repo help --all' for a complete list of recognized commands. try: cmd = self.commands[name] except KeyError: - print >>sys.stderr, "repo: '%s' is not a repo command." % name + print("repo: '%s' is not a repo command." % name, file=sys.stderr) sys.exit(1) cmd.manifest = self.manifest -- cgit v1.2.3-54-g00ecf