]> granicus.if.org Git - python/commitdiff
Packaging cleanup: normalize print calls.
authorÉric Araujo <merwok@netwok.org>
Wed, 8 Jun 2011 02:10:57 +0000 (04:10 +0200)
committerÉric Araujo <merwok@netwok.org>
Wed, 8 Jun 2011 02:10:57 +0000 (04:10 +0200)
Namely: use default arguments instead of explicit empty string; use multiple
arguments instead of building strings.

Lib/packaging/depgraph.py
Lib/packaging/dist.py
Lib/packaging/run.py
Lib/packaging/util.py

index 48ea3d925216b9db44cfc5ac1f6ab70837ed8e6c..9f3d6c35b408d97b1b19753722c09df2b4ca52e3 100644 (file)
@@ -236,7 +236,9 @@ def main():
     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 @@ def main():
     # 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:
index 6065e78a6a93380f87ca462eb7eb6df0c4a65324..5c390ce9d19780fdbdadd9aeed842cd2ff148466 100644 (file)
@@ -509,14 +509,14 @@ Common commands: (see '--help-commands' for more)
                 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 @@ Common commands: (see '--help-commands' for more)
             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 @@ Common commands: (see '--help-commands' for more)
         # we ignore "foo bar").
         if self.help_commands:
             self.print_commands()
-            print('')
+            print()
             print(gen_usage(self.script_name))
             return 1
 
index 3afda5af5e629a34b42068611a6c27f19d7f46a5..3e720cf7e8e5423c02ed44bb19a7afbb253623e4 100644 (file)
@@ -286,9 +286,9 @@ def _metadata(dispatcher, args, **kw):
             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 @@ def _list(dispatcher, args, **kw):
         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 @@ class Dispatcher:
         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 @@ class Dispatcher:
                 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 @@ class Dispatcher:
             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
index d4aae418dd86b2c4f01baa22e148075eb553a936..812dbe3c29f8685d8b75a94bf4ceec578bf40013 100644 (file)
@@ -1099,7 +1099,7 @@ def ask(message, options):
         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