| Index: third_party/logilab/common/clcommands.py
|
| diff --git a/third_party/logilab/common/clcommands.py b/third_party/logilab/common/clcommands.py
|
| index 4778b99b024e0f2eb816d64f34be6b8f46542d80..411931bbfbc8e2b3bf3ec9faf82b4c719c633c0a 100644
|
| --- a/third_party/logilab/common/clcommands.py
|
| +++ b/third_party/logilab/common/clcommands.py
|
| @@ -22,8 +22,6 @@ e.g called as "tool command [options] args..." where <options> and <args> are
|
| command'specific
|
| """
|
|
|
| -from __future__ import print_function
|
| -
|
| __docformat__ = "restructuredtext en"
|
|
|
| import sys
|
| @@ -117,7 +115,7 @@ class CommandLine(dict):
|
| if arg in ('-h', '--help'):
|
| self.usage_and_exit(0)
|
| if self.version is not None and arg in ('--version'):
|
| - print(self.version)
|
| + print self.version
|
| sys.exit(0)
|
| rcfile = self.rcfile
|
| if rcfile is not None and arg in ('-C', '--rc-file'):
|
| @@ -129,21 +127,21 @@ class CommandLine(dict):
|
| try:
|
| command = self.get_command(arg)
|
| except KeyError:
|
| - print('ERROR: no %s command' % arg)
|
| - print()
|
| + print 'ERROR: no %s command' % arg
|
| + print
|
| self.usage_and_exit(1)
|
| try:
|
| sys.exit(command.main_run(args, rcfile))
|
| - except KeyboardInterrupt as exc:
|
| - print('Interrupted', end=' ')
|
| + except KeyboardInterrupt, exc:
|
| + print 'Interrupted',
|
| if str(exc):
|
| - print(': %s' % exc, end=' ')
|
| - print()
|
| + print ': %s' % exc,
|
| + print
|
| sys.exit(4)
|
| - except BadCommandUsage as err:
|
| - print('ERROR:', err)
|
| - print()
|
| - print(command.help())
|
| + except BadCommandUsage, err:
|
| + print 'ERROR:', err
|
| + print
|
| + print command.help()
|
| sys.exit(1)
|
|
|
| def create_logger(self, handler, logthreshold=None):
|
| @@ -166,32 +164,32 @@ class CommandLine(dict):
|
| """display usage for the main program (i.e. when no command supplied)
|
| and exit
|
| """
|
| - print('usage:', self.pgm, end=' ')
|
| + print 'usage:', self.pgm,
|
| if self.rcfile:
|
| - print('[--rc-file=<configuration file>]', end=' ')
|
| - print('<command> [options] <command argument>...')
|
| + print '[--rc-file=<configuration file>]',
|
| + print '<command> [options] <command argument>...'
|
| if self.doc:
|
| - print('\n%s' % self.doc)
|
| - print('''
|
| + print '\n%s' % self.doc
|
| + print '''
|
| Type "%(pgm)s <command> --help" for more information about a specific
|
| -command. Available commands are :\n''' % self.__dict__)
|
| +command. Available commands are :\n''' % self.__dict__
|
| max_len = max([len(cmd) for cmd in self])
|
| padding = ' ' * max_len
|
| for cmdname, cmd in sorted(self.items()):
|
| if not cmd.hidden:
|
| - print(' ', (cmdname + padding)[:max_len], cmd.short_description())
|
| + print ' ', (cmdname + padding)[:max_len], cmd.short_description()
|
| if self.rcfile:
|
| - print('''
|
| + print '''
|
| Use --rc-file=<configuration file> / -C <configuration file> before the command
|
| to specify a configuration file. Default to %s.
|
| -''' % self.rcfile)
|
| - print('''%(pgm)s -h/--help
|
| - display this usage information and exit''' % self.__dict__)
|
| +''' % self.rcfile
|
| + print '''%(pgm)s -h/--help
|
| + display this usage information and exit''' % self.__dict__
|
| if self.version:
|
| - print('''%(pgm)s -v/--version
|
| - display version configuration and exit''' % self.__dict__)
|
| + print '''%(pgm)s -v/--version
|
| + display version configuration and exit''' % self.__dict__
|
| if self.copyright:
|
| - print('\n', self.copyright)
|
| + print '\n', self.copyright
|
|
|
| def usage_and_exit(self, status):
|
| self.usage()
|
| @@ -263,7 +261,7 @@ class Command(Configuration):
|
| try:
|
| self.check_args(args)
|
| self.run(args)
|
| - except CommandError as err:
|
| + except CommandError, err:
|
| self.logger.error(err)
|
| return 2
|
| return 0
|
| @@ -285,14 +283,14 @@ class ListCommandsCommand(Command):
|
| command = args.pop()
|
| cmd = _COMMANDS[command]
|
| for optname, optdict in cmd.options:
|
| - print('--help')
|
| - print('--' + optname)
|
| + print '--help'
|
| + print '--' + optname
|
| else:
|
| commands = sorted(_COMMANDS.keys())
|
| for command in commands:
|
| cmd = _COMMANDS[command]
|
| if not cmd.hidden:
|
| - print(command)
|
| + print command
|
|
|
|
|
| # deprecated stuff #############################################################
|
|
|