[Python-checkins] cpython: Packaging cleanup: normalize print calls.

eric.araujo python-checkins at python.org
Thu Jun 9 14:10:57 CEST 2011


http://hg.python.org/cpython/rev/743b367debf1
changeset: 70719:743b367debf1
user: Éric Araujo <merwok at netwok.org>
date: Wed Jun 08 04:10:57 2011 +0200
summary:
 Packaging cleanup: normalize print calls.
Namely: use default arguments instead of explicit empty string; use multiple
arguments instead of building strings.
files:
 Lib/packaging/depgraph.py | 6 ++++--
 Lib/packaging/dist.py | 8 ++++----
 Lib/packaging/run.py | 20 ++++++++++----------
 Lib/packaging/util.py | 2 +-
 4 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/Lib/packaging/depgraph.py b/Lib/packaging/depgraph.py
--- a/Lib/packaging/depgraph.py
+++ b/Lib/packaging/depgraph.py
@@ -236,7 +236,9 @@
 except Exception as e:
 tempout.seek(0)
 tempout = tempout.read()
- print('Could not generate the graph\n%s\n%s\n' % (tempout, e))
+ print('Could not generate the graph')
+ print(tempout)
+ print(e)
 sys.exit(1)
 
 for dist, reqs in graph.missing.items():
@@ -246,7 +248,7 @@
 # XXX replace with argparse
 if len(sys.argv) == 1:
 print('Dependency graph:')
- print(' ' + repr(graph).replace('\n', '\n '))
+ 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:
diff --git a/Lib/packaging/dist.py b/Lib/packaging/dist.py
--- a/Lib/packaging/dist.py
+++ b/Lib/packaging/dist.py
@@ -509,14 +509,14 @@
 options = self.global_options
 parser.set_option_table(options)
 parser.print_help(self.common_usage + "\nGlobal options:")
- print('')
+ print()
 
 if display_options:
 parser.set_option_table(self.display_options)
 parser.print_help(
 "Information display options (just display " +
 "information, ignore any commands)")
- print('')
+ print()
 
 for command in self.commands:
 if isinstance(command, type) and issubclass(command, Command):
@@ -529,7 +529,7 @@
 else:
 parser.set_option_table(cls.user_options)
 parser.print_help("Options for %r command:" % cls.__name__)
- print('')
+ print()
 
 print(gen_usage(self.script_name))
 
@@ -544,7 +544,7 @@
 # we ignore "foo bar").
 if self.help_commands:
 self.print_commands()
- print('')
+ print()
 print(gen_usage(self.script_name))
 return 1
 
diff --git a/Lib/packaging/run.py b/Lib/packaging/run.py
--- a/Lib/packaging/run.py
+++ b/Lib/packaging/run.py
@@ -286,9 +286,9 @@
 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)
@@ -366,7 +366,7 @@
 print('%s %s at %s' % (dist.name, dist.metadata['version'], dist.path))
 number += 1
 
- print('')
+ print()
 if number == 0:
 print('Nothing seems to be installed.')
 else:
@@ -573,17 +573,17 @@
 from packaging.command.cmd import Command
 
 print('Usage: pysetup [options] action [action_options]')
- print('')
+ 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):
@@ -597,15 +597,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, str):
 command = get_command_class(command)
 
 desc = getattr(command, 'description', '(no description available)')
- print('Description: %s' % desc)
- print('')
+ print('Description:', desc)
+ print()
 
 if (hasattr(command, 'help_options') and
 isinstance(command.help_options, list)):
@@ -615,7 +615,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
diff --git a/Lib/packaging/util.py b/Lib/packaging/util.py
--- a/Lib/packaging/util.py
+++ b/Lib/packaging/util.py
@@ -1099,7 +1099,7 @@
 response = input(message)
 response = response.strip().lower()
 if response not in options:
- print('invalid response: %r' % response)
+ 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/cpython


More information about the Python-checkins mailing list

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