Description: Adds Python 3 compat.
Author: Thomas Goirand <zigo@debian.org>
Forwarded: no
Last-Update: 2014-08-29

--- python-googlecloudapis-0.9.30+debian1.orig/googlecloudapis/apitools/base/py/app2.py
+++ python-googlecloudapis-0.9.30+debian1/googlecloudapis/apitools/base/py/app2.py
@@ -101,9 +101,9 @@ class NewCmd(appcommands.Cmd):
       fail = 'Too many positional args; found %d, expected at most %d' % (
           len(args), self._max_args)
     if fail:
-      print fail
+      print(fail)
       if self.usage:
-        print 'Usage: %s' % (self.usage,)
+        print('Usage: %s' % (self.usage,))
       return 1
 
     if self._debug_mode:
@@ -131,7 +131,7 @@ class NewCmd(appcommands.Cmd):
 
   def _HandleError(self, e):
     message = self._FormatError(e)
-    print 'Exception raised in %s operation: %s' % (self._command_name, message)
+    print('Exception raised in %s operation: %s' % (self._command_name, message))
     return 1
 
   def _IsDebuggableException(self, e):
@@ -142,20 +142,20 @@ class NewCmd(appcommands.Cmd):
     """Run this command in debug mode."""
     try:
       return_value = self.RunWithArgs(*args, **kwds)
-    except BaseException, e:
+    except BaseException as e:
       # Don't break into the debugger for expected exceptions.
       if not self._IsDebuggableException(e):
         return self._HandleError(e)
       print
-      print '****************************************************'
-      print '**   Unexpected Exception raised in execution!    **'
+      print('****************************************************')
+      print('**   Unexpected Exception raised in execution!    **')
       if FLAGS.headless:
-        print '**  --headless mode enabled, exiting.             **'
-        print '**  See STDERR for traceback.                     **'
+        print('**  --headless mode enabled, exiting.             **')
+        print('**  See STDERR for traceback.                     **')
       else:
-        print '**  --debug_mode enabled, starting pdb.           **'
-      print '****************************************************'
-      print
+        print('**  --debug_mode enabled, starting pdb.           **')
+      print('****************************************************')
+      print('')
       traceback.print_exc()
       print
       if not FLAGS.headless:
@@ -167,7 +167,7 @@ class NewCmd(appcommands.Cmd):
     """Run this command, turning exceptions into print statements."""
     try:
       return_value = self.RunWithArgs(*args, **kwds)
-    except BaseException, e:
+    except BaseException as e:
       return self._HandleError(e)
     return return_value
 
@@ -218,7 +218,7 @@ class CommandLoop(cmd.Cmd):
     raise CommandLoop.TerminateSignal()
 
   def postloop(self):
-    print 'Goodbye.'
+    print('Goodbye.')
 
   def completedefault(self, unused_text, line, unused_begidx, unused_endidx):
     if not line:
@@ -230,13 +230,13 @@ class CommandLoop(cmd.Cmd):
         usage = self._commands[command_name].usage
       if usage:
         print
-        print usage
-        print '%s%s' % (self.prompt, line),
+        print(usage)
+        print('%s%s' % (self.prompt, line))
       return []
 
   def emptyline(self):
-    print 'Available commands:',
-    print ' '.join(list(self._commands))
+    print('Available commands:')
+    print(' '.join(list(self._commands)))
 
   def precmd(self, line):
     """Preprocess the shell input."""
@@ -268,8 +268,8 @@ class CommandLoop(cmd.Cmd):
       return True
     except BaseException as e:
       name = line.split(' ')[0]
-      print 'Error running %s:' % name
-      print e
+      print('Error running %s:' % name)
+      print(e)
       self._last_return_code = 1
     return False
 
@@ -304,16 +304,16 @@ class CommandLoop(cmd.Cmd):
             firstline_indent=default_indent) + '\n'
 
     if not command_name:
-      print '\nHelp for commands:\n'
+      print('\nHelp for commands:\n')
       command_names = list(self._commands)
-      print '\n\n'.join(
+      print('\n\n'.join(
           FormatOneCmd(name, command, command_names)
           for name, command in self._commands.iteritems()
-          if name not in self._special_command_names)
-      print
+          if name not in self._special_command_names))
+      print('')
     elif command_name in self._commands:
-      print FormatOneCmd(command_name, self._commands[command_name],
-                         command_names=[command_name])
+      print(FormatOneCmd(command_name, self._commands[command_name],
+                         command_names=[command_name]))
     return 0
 
   def postcmd(self, stop, line):
@@ -337,7 +337,7 @@ class Repl(NewCmd):
     """Start an interactive session."""
     prompt = FLAGS.prompt or self.PROMPT
     repl = CommandLoop(appcommands.GetCommandList(), prompt=prompt)
-    print 'Welcome! (Type help for more information.)'
+    print('Welcome! (Type help for more information.)')
     while True:
       try:
         repl.cmdloop()
--- python-googlecloudapis-0.9.30+debian1.orig/googlecloudapis/apitools/base/py/credentials_lib.py
+++ python-googlecloudapis-0.9.30+debian1/googlecloudapis/apitools/base/py/credentials_lib.py
@@ -195,7 +195,7 @@ def CredentialsFromFile(path, client_inf
     flags.FLAGS.auth_local_webserver = False
   credentials = credential_store.get()
   if credentials is None or credentials.invalid:
-    print 'Generating new OAuth credentials ...'
+    print('Generating new OAuth credentials ...')
     while True:
       # If authorization fails, we want to retry, rather than let this
       # cascade up and get caught elsewhere. If users want out of the
@@ -208,9 +208,9 @@ def CredentialsFromFile(path, client_inf
         # Here SystemExit is "no credential at all", and the
         # FlowExchangeError is "invalid" -- usually because you reused
         # a token.
-        print 'Invalid authorization: %s' % (e,)
+        print('Invalid authorization: %s' % (e,))
       except httplib2.HttpLib2Error as e:
-        print 'Communication error: %s' % (e,)
+        print('Communication error: %s' % (e,))
         raise exceptions.CredentialsError(
             'Communication error creating credentials: %s' % e)
   return credentials
--- python-googlecloudapis-0.9.30+debian1.orig/googlecloudapis/apitools/base/py/transfer.py
+++ python-googlecloudapis-0.9.30+debian1/googlecloudapis/apitools/base/py/transfer.py
@@ -38,7 +38,7 @@ class _Transfer(object):
     self.__url = None
 
     self.auto_transfer = auto_transfer
-    self.chunksize = chunksize or 1048576L
+    self.chunksize = chunksize or 1048576
 
   def __repr__(self):
     return str(self)
@@ -242,13 +242,13 @@ class Download(_Transfer):
   @staticmethod
   def _ArgPrinter(response, unused_download):
     if 'content-range' in response.info:
-      print 'Received %s' % response.info['content-range']
+      print('Received %s' % response.info['content-range'])
     else:
-      print 'Received %d bytes' % len(response)
+      print('Received %d bytes' % len(response))
 
   @staticmethod
   def _CompletePrinter(*unused_args):
-    print 'Download complete'
+    print('Download complete')
 
   def __NormalizeStartEnd(self, start, end=None):
     if end is not None:
@@ -651,11 +651,11 @@ class Upload(_Transfer):
 
   @staticmethod
   def _ArgPrinter(response, unused_upload):
-    print 'Sent %s' % response.info['range']
+    print('Sent %s' % response.info['range'])
 
   @staticmethod
   def _CompletePrinter(*unused_args):
-    print 'Upload complete'
+    print('Upload complete')
 
   def StreamInChunks(self, callback=None, finish_callback=None,
                      additional_headers=None):
