@@ -203,7 +203,7 @@ def build(serviceName,
203203 cache )
204204 except HttpError as e :
205205 if e .resp .status == http_client .NOT_FOUND :
206- raise UnknownApiNameOrVersion ("name: %s version: %s" % (serviceName ,
206+ raise UnknownApiNameOrVersion ("name: {0!s} version: {1!s}" . format (serviceName ,
207207 version ))
208208 else :
209209 raise e
@@ -407,11 +407,11 @@ def _media_path_url_from_info(root_desc, path_url):
407407 Returns:
408408 String; the absolute URI for media upload for the API method.
409409 """
410- return '%( root)supload/%( service_path)s%( path)s' % {
410+ return '{ root!s}upload/{ service_path!s}{ path!s}' . format ( ** {
411411 'root' : root_desc ['rootUrl' ],
412412 'service_path' : root_desc ['servicePath' ],
413413 'path' : path_url ,
414- }
414+ })
415415
416416
417417def _fix_up_parameters (method_desc , root_desc , http_method ):
@@ -673,7 +673,7 @@ def method(self, **kwargs):
673673
674674 for name in six .iterkeys (kwargs ):
675675 if name not in parameters .argmap :
676- raise TypeError ('Got an unexpected keyword argument "%s"' % name )
676+ raise TypeError ('Got an unexpected keyword argument "{0!s}"' . format ( name ) )
677677
678678 # Remove args that have a value of None.
679679 keys = list (kwargs .keys ())
@@ -683,7 +683,7 @@ def method(self, **kwargs):
683683
684684 for name in parameters .required_params :
685685 if name not in kwargs :
686- raise TypeError ('Missing required parameter "%s"' % name )
686+ raise TypeError ('Missing required parameter "{0!s}"' . format ( name ) )
687687
688688 for name , regex in six .iteritems (parameters .pattern_params ):
689689 if name in kwargs :
@@ -694,8 +694,7 @@ def method(self, **kwargs):
694694 for pvalue in pvalues :
695695 if re .match (regex , pvalue ) is None :
696696 raise TypeError (
697- 'Parameter "%s" value "%s" does not match the pattern "%s"' %
698- (name , pvalue , regex ))
697+ 'Parameter "{0!s}" value "{1!s}" does not match the pattern "{2!s}"' .format (name , pvalue , regex ))
699698
700699 for name , enums in six .iteritems (parameters .enum_params ):
701700 if name in kwargs :
@@ -710,8 +709,7 @@ def method(self, **kwargs):
710709 for value in values :
711710 if value not in enums :
712711 raise TypeError (
713- 'Parameter "%s" value "%s" is not an allowed value in "%s"' %
714- (name , value , str (enums )))
712+ 'Parameter "{0!s}" value "{1!s}" is not an allowed value in "{2!s}"' .format (name , value , str (enums )))
715713
716714 actual_query_params = {}
717715 actual_path_params = {}
@@ -765,7 +763,7 @@ def method(self, **kwargs):
765763
766764 # Check the maxSize
767765 if media_upload .size () is not None and media_upload .size () > maxSize > 0 :
768- raise MediaUploadSizeError ("Media larger than: %s" % maxSize )
766+ raise MediaUploadSizeError ("Media larger than: {0!s}" . format ( maxSize ) )
769767
770768 # Use the media path uri for media uploads
771769 expanded_url = uritemplate .expand (mediaPathUrl , params )
@@ -814,7 +812,7 @@ def method(self, **kwargs):
814812 'boundary="%s"' ) % multipart_boundary
815813 url = _add_query_parameter (url , 'uploadType' , 'multipart' )
816814
817- logger .info ('URL being requested: %s %s' % (httpMethod ,url ))
815+ logger .info ('URL being requested: {0!s} {1!s}' . format (httpMethod , url ))
818816 return self ._requestBuilder (self ._http ,
819817 model .response ,
820818 url ,
@@ -862,14 +860,14 @@ def method(self, **kwargs):
862860 schema .prettyPrintByName (paramdesc ['$ref' ])))
863861 else :
864862 paramtype = paramdesc .get ('type' , 'string' )
865- docs .append (' %s: %s, %s%s%s \n ' % (arg , paramtype , paramdoc , required ,
863+ docs .append (' {0!s}: {1!s}, {2!s}{3!s}{4!s} \n ' . format (arg , paramtype , paramdoc , required ,
866864 repeated ))
867865 enum = paramdesc .get ('enum' , [])
868866 enumDesc = paramdesc .get ('enumDescriptions' , [])
869867 if enum and enumDesc :
870868 docs .append (' Allowed values\n ' )
871869 for (name , desc ) in zip (enum , enumDesc ):
872- docs .append (' %s - %s \n ' % (name , desc ))
870+ docs .append (' {0!s} - {1!s} \n ' . format (name , desc ))
873871 if 'response' in methodDesc :
874872 if methodName .endswith ('_media' ):
875873 docs .append ('\n Returns:\n The media object as a string.\n \n ' )
@@ -922,7 +920,7 @@ def methodNext(self, previous_request, previous_response):
922920
923921 request .uri = uri
924922
925- logger .info ('URL being requested: %s %s' % (methodName ,uri ))
923+ logger .info ('URL being requested: {0!s} {1!s}' . format (methodName , uri ))
926924
927925 return request
928926
@@ -1004,7 +1002,7 @@ def _set_service_methods(self):
10041002 def _add_basic_methods (self , resourceDesc , rootDesc , schema ):
10051003 # If this is the root Resource, add a new_batch_http_request() method.
10061004 if resourceDesc == rootDesc :
1007- batch_uri = '%s%s' % (
1005+ batch_uri = '{0!s}{1!s}' . format (
10081006 rootDesc ['rootUrl' ], rootDesc .get ('batchPath' , 'batch' ))
10091007 def new_batch_http_request (callback = None ):
10101008 """Create a BatchHttpRequest object based on the discovery document.
0 commit comments