[Python-checkins] distutils2: Convert print function calls back to print statements.

eric.araujo python-checkins at python.org
Tue Sep 13 13:43:49 CEST 2011


http://hg.python.org/distutils2/rev/61f2bd107258
changeset: 1141:61f2bd107258
parent: 1133:20f69a01ae38
user: Éric Araujo <merwok at netwok.org>
date: Mon Sep 12 01:39:51 2011 +0200
summary:
 Convert print function calls back to print statements.
This caused pysetup to print out tuples. When multi-line strings are
enclosed in parens for line-wrapping purposes, which would not print out
a tuple, I have added a space for clarity anyway.
files:
 distutils2/_backport/tests/test_sysconfig.py | 2 +-
 distutils2/command/register.py | 4 +-
 distutils2/create.py | 38 +++++-----
 distutils2/depgraph.py | 20 ++--
 distutils2/dist.py | 24 +++---
 distutils2/run.py | 38 +++++-----
 distutils2/tests/support.py | 6 +-
 distutils2/tests/test_command_build_ext.py | 4 +-
 distutils2/util.py | 4 +-
 9 files changed, 70 insertions(+), 70 deletions(-)
diff --git a/distutils2/_backport/tests/test_sysconfig.py b/distutils2/_backport/tests/test_sysconfig.py
--- a/distutils2/_backport/tests/test_sysconfig.py
+++ b/distutils2/_backport/tests/test_sysconfig.py
@@ -251,7 +251,7 @@
 # Issue 7880
 def get(python):
 cmd = [python, '-c',
- 'import sysconfig; print(sysconfig.get_platform())']
+ 'import sysconfig; print sysconfig.get_platform()']
 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=os.environ)
 return p.communicate()
 real = os.path.realpath(sys.executable)
diff --git a/distutils2/command/register.py b/distutils2/command/register.py
--- a/distutils2/command/register.py
+++ b/distutils2/command/register.py
@@ -148,7 +148,7 @@
 if not choice:
 choice = '1'
 elif choice not in choices:
- print('Please choose one of the four options!')
+ print 'Please choose one of the four options!'
 
 if choice == '1':
 # get the username and password
@@ -199,7 +199,7 @@
 if data['password'] != data['confirm']:
 data['password'] = ''
 data['confirm'] = None
- print("Password and confirm don't match!")
+ print "Password and confirm don't match!"
 while not data['email']:
 data['email'] = input(' EMail: ')
 code, result = self.post_to_server(data)
diff --git a/distutils2/create.py b/distutils2/create.py
--- a/distutils2/create.py
+++ b/distutils2/create.py
@@ -130,7 +130,7 @@
 if answer and answer[0].lower() in 'yn':
 return answer[0].lower()
 
- print('\nERROR: You must select "Y" or "N".\n')
+ print '\nERROR: You must select "Y" or "N".\n'
 
 
 def ask(question, default=None, helptext=None, required=True,
@@ -154,19 +154,19 @@
 
 line = sys.stdin.readline().strip()
 if line == '?':
- print('=' * 70)
- print(helptext)
- print('=' * 70)
+ print '=' * 70
+ print helptext
+ print '=' * 70
 continue
 if default and not line:
 return default
 if not line and required:
- print('*' * 70)
- print('This value cannot be empty.')
- print('===========================')
+ print '*' * 70
+ print 'This value cannot be empty.'
+ print '==========================='
 if helptext:
- print(helptext)
- print('*' * 70)
+ print helptext
+ print '*' * 70
 continue
 return line
 
@@ -273,9 +273,9 @@
 def _write_cfg(self):
 if os.path.exists(_FILENAME):
 if os.path.exists('%s.old' % _FILENAME):
- print("ERROR: %(name)s.old backup exists, please check that "
- "current %(name)s is correct and remove %(name)s.old" %
- {'name': _FILENAME})
+ print ('ERROR: %(name)s.old backup exists, please check that '
+ 'current %(name)s is correct and remove %(name)s.old' %
+ {'name': _FILENAME})
 return
 shutil.move(_FILENAME, '%s.old' % _FILENAME)
 
@@ -324,7 +324,7 @@
 fp.close()
 
 os.chmod(_FILENAME, 00644)
- print('Wrote "%s".' % _FILENAME)
+ print 'Wrote %r.' % _FILENAME
 
 def convert_py_to_cfg(self):
 """Generate a setup.cfg from an existing setup.py.
@@ -631,8 +631,8 @@
 break
 
 if len(found_list) == 0:
- print('ERROR: Could not find a matching license for "%s"' %
- license)
+ print ('ERROR: Could not find a matching license for "%s"' %
+ license)
 continue
 
 question = 'Matching licenses:\n\n'
@@ -653,8 +653,8 @@
 try:
 index = found_list[int(choice) - 1]
 except ValueError:
- print("ERROR: Invalid selection, type a number from the list "
- "above.")
+ print ('ERROR: Invalid selection, type a number from the list '
+ 'above.')
 
 classifiers.add(_CLASSIFIERS_LIST[index])
 
@@ -677,8 +677,8 @@
 classifiers.add(key)
 return
 except (IndexError, ValueError):
- print("ERROR: Invalid selection, type a single digit "
- "number.")
+ print ('ERROR: Invalid selection, type a single digit '
+ 'number.')
 
 
 def main():
diff --git a/distutils2/depgraph.py b/distutils2/depgraph.py
--- a/distutils2/depgraph.py
+++ b/distutils2/depgraph.py
@@ -238,19 +238,19 @@
 e = sys.exc_info()[1]
 tempout.seek(0)
 tempout = tempout.read()
- print(u'Could not generate the graph')
- print(tempout)
- print(e)
+ print 'Could not generate the graph'
+ print tempout
+ print e
 sys.exit(1)
 
 for dist, reqs in graph.missing.items():
 if len(reqs) > 0:
- print(u"Warning: Missing dependencies for %r:" % dist.name,
- ", ".join(reqs))
+ print 'Warning: Missing dependencies for %r:' % dist.name, \
+ ', '.join(reqs)
 # XXX replace with argparse
 if len(sys.argv) == 1:
- print(u'Dependency graph:')
- print(u' ', repr(graph).replace(u'\n', u'\n '))
+ print 'Dependency graph:'
+ print ' ', repr(graph).replace('\n', '\n ')
 sys.exit(0)
 elif len(sys.argv) > 1 and sys.argv[1] in ('-d', '--dot'):
 if len(sys.argv) > 2:
@@ -263,11 +263,11 @@
 f.close()
 tempout.seek(0)
 tempout = tempout.read()
- print(tempout)
- print('Dot file written at %r' % filename)
+ print tempout
+ print 'Dot file written at %r' % filename
 sys.exit(0)
 else:
- print('Supported option: -d [filename]')
+ print 'Supported option: -d [filename]'
 sys.exit(1)
 
 
diff --git a/distutils2/dist.py b/distutils2/dist.py
--- a/distutils2/dist.py
+++ b/distutils2/dist.py
@@ -511,14 +511,14 @@
 options = self.global_options
 parser.set_option_table(options)
 parser.print_help(self.common_usage + "\nGlobal options:")
- print(u'')
+ print
 
 if display_options:
 parser.set_option_table(self.display_options)
 parser.print_help(
 "Information display options (just display " +
 "information, ignore any commands)")
- print(u'')
+ print
 
 for command in self.commands:
 if isinstance(command, type) and issubclass(command, Command):
@@ -531,9 +531,9 @@
 else:
 parser.set_option_table(cls.user_options)
 parser.print_help("Options for %r command:" % cls.__name__)
- print(u'')
+ print
 
- print(gen_usage(self.script_name))
+ print gen_usage(self.script_name)
 
 def handle_display_options(self, option_order):
 """If there were any non-global "display-only" options
@@ -546,8 +546,8 @@
 # we ignore "foo bar").
 if self.help_commands:
 self.print_commands()
- print()
- print(gen_usage(self.script_name))
+ print
+ print gen_usage(self.script_name)
 return 1
 
 # If user supplied any of the "display metadata" options, then
@@ -563,12 +563,12 @@
 opt = opt.replace('-', '_')
 value = self.metadata[opt]
 if opt in ('keywords', 'platform'):
- print(','.join(value))
+ print ','.join(value)
 elif opt in ('classifier', 'provides', 'requires',
 'obsoletes'):
- print('\n'.join(value))
+ print '\n'.join(value)
 else:
- print(value)
+ print value
 any_display_options = True
 
 return any_display_options
@@ -577,14 +577,14 @@
 """Print a subset of the list of all commands -- used by
 'print_commands()'.
 """
- print(header + ":")
+ print header + ":"
 
 for cmd in commands:
 cls = self.cmdclass.get(cmd) or get_command_class(cmd)
 description = getattr(cls, 'description',
 '(no description available)')
 
- print(" %-*s %s" % (max_length, cmd, description))
+ print " %-*s %s" % (max_length, cmd, description)
 
 def _get_command_groups(self):
 """Helper function to retrieve all the command class names divided
@@ -614,7 +614,7 @@
 "Standard commands",
 max_length)
 if extra_commands:
- print()
+ print
 self.print_command_list(extra_commands,
 "Extra commands",
 max_length)
diff --git a/distutils2/run.py b/distutils2/run.py
--- a/distutils2/run.py
+++ b/distutils2/run.py
@@ -199,7 +199,7 @@
 def wrapper(*args, **kwargs):
 f_args = args[1]
 if '--help' in f_args or '-h' in f_args:
- print(self.help_msg)
+ print self.help_msg
 return
 return f(*args, **kwargs)
 return wrapper
@@ -227,7 +227,7 @@
 else:
 dists = get_distributions(use_egg_info=True)
 graph = generate_graph(dists)
- print(graph.repr_node(dist))
+ print graph.repr_node(dist)
 
 
 @action_help(install_usage)
@@ -279,13 +279,13 @@
 
 for key in keys:
 if key in metadata:
- print(metadata._convert_name(key) + ':')
+ print metadata._convert_name(key) + ':'
 value = metadata[key]
 if isinstance(value, list):
 for v in value:
- print(' ', v)
+ print ' ', v
 else:
- print(' ', value.replace('\n', '\n '))
+ print ' ', value.replace('\n', '\n ')
 
 
 @action_help(remove_usage)
@@ -315,14 +315,14 @@
 commands = STANDARD_COMMANDS # + extra commands
 
 if args == ['--list-commands']:
- print('List of available commands:')
+ print 'List of available commands:'
 cmds = sorted(commands)
 
 for cmd in cmds:
 cls = dispatcher.cmdclass.get(cmd) or get_command_class(cmd)
 desc = getattr(cls, 'description',
 '(no description available)')
- print(' %s: %s' % (cmd, desc))
+ print ' %s: %s' % (cmd, desc)
 return
 
 while args:
@@ -360,7 +360,7 @@
 
 number = 0
 for dist in results:
- print('%r %s (from %r)' % (dist.name, dist.version, dist.path))
+ print '%r %s (from %r)' % (dist.name, dist.version, dist.path)
 number += 1
 
 if number == 0:
@@ -573,18 +573,18 @@
 # late import because of mutual dependence between these modules
 from distutils2.command.cmd import Command
 
- print('Usage: pysetup [options] action [action_options]')
- print()
+ print 'Usage: pysetup [options] action [action_options]'
+ print
 if global_options_:
 self.print_usage(self.parser)
- print()
+ print
 
 if display_options_:
 parser.set_option_table(display_options)
 parser.print_help(
 "Information display options (just display " +
 "information, ignore any commands)")
- print()
+ print
 
 for command in commands:
 if isinstance(command, type) and issubclass(command, Command):
@@ -598,15 +598,15 @@
 parser.set_option_table(cls.user_options)
 
 parser.print_help("Options for %r command:" % cls.__name__)
- print()
+ print
 
 def _show_command_help(self, command):
 if isinstance(command, basestring):
 command = get_command_class(command)
 
 desc = getattr(command, 'description', '(no description available)')
- print('Description:', desc)
- print()
+ print 'Description:', desc
+ print
 
 if (hasattr(command, 'help_options') and
 isinstance(command.help_options, list)):
@@ -616,7 +616,7 @@
 self.parser.set_option_table(command.user_options)
 
 self.parser.print_help("Options:")
- print()
+ print
 
 def _get_command_groups(self):
 """Helper function to retrieve all the command class names divided
@@ -643,7 +643,7 @@
 
 self.print_command_list(std_commands, "Standard commands", max_length)
 if extra_commands:
- print()
+ print
 self.print_command_list(extra_commands, "Extra commands",
 max_length)
 
@@ -651,14 +651,14 @@
 """Print a subset of the list of all commands -- used by
 'print_commands()'.
 """
- print(header + ":")
+ print header + ":"
 
 for cmd in commands:
 cls = self.cmdclass.get(cmd) or get_command_class(cmd)
 description = getattr(cls, 'description',
 '(no description available)')
 
- print(" %-*s %s" % (max_length, cmd, description))
+ print " %-*s %s" % (max_length, cmd, description)
 
 def __call__(self):
 if self.action is None:
diff --git a/distutils2/tests/support.py b/distutils2/tests/support.py
--- a/distutils2/tests/support.py
+++ b/distutils2/tests/support.py
@@ -326,9 +326,9 @@
 except UnicodeEncodeError:
 pass
 else:
- print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
- 'Unicode filename tests may not be effective'
- % (TESTFN_UNENCODABLE, TESTFN_ENCODING))
+ print ('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
+ 'Unicode filename tests may not be effective'
+ % (TESTFN_UNENCODABLE, TESTFN_ENCODING))
 TESTFN_UNENCODABLE = None
 # Mac OS X denies unencodable filenames (invalid utf-8)
 elif sys.platform != 'darwin':
diff --git a/distutils2/tests/test_command_build_ext.py b/distutils2/tests/test_command_build_ext.py
--- a/distutils2/tests/test_command_build_ext.py
+++ b/distutils2/tests/test_command_build_ext.py
@@ -465,8 +465,8 @@
 src = _get_source_filename()
 if not os.path.exists(src):
 if verbose:
- print('test_command_build_ext: Cannot find source code (test'
- ' must run in python build dir)')
+ print ('test_command_build_ext: Cannot find source code (test'
+ ' must run in python build dir)')
 return unittest.TestSuite()
 else:
 return unittest.makeSuite(BuildExtTestCase)
diff --git a/distutils2/util.py b/distutils2/util.py
--- a/distutils2/util.py
+++ b/distutils2/util.py
@@ -1159,8 +1159,8 @@
 response = input(message)
 response = response.strip().lower()
 if response not in options:
- print('invalid response:', repr(response))
- print('choose one of', ', '.join(repr(o) for o in options))
+ print 'invalid response:', repr(response)
+ print 'choose one of', ', '.join(repr(o) for o in options)
 else:
 return response
 
-- 
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /