@@ -183,7 +183,8 @@ class QiitaClient(object):
183183 get
184184 post
185185 """
186- def __init__ (self , server_url , client_id , client_secret , ca_cert = None , plugincoupling = 'filesystem' ):
186+ def __init__ (self , server_url , client_id , client_secret , ca_cert = None ,
187+ plugincoupling = 'filesystem' ):
187188 self ._server_url = server_url
188189 self ._session = requests .Session ()
189190
@@ -367,7 +368,8 @@ def _request_retry(self, req, url, rettype='json', **kwargs):
367368 retries = MAX_RETRIES
368369 while retries > 0 :
369370 retries -= 1
370- r = self ._request_oauth2 (req , rettype , url , verify = self ._verify , ** kwargs )
371+ r = self ._request_oauth2 (
372+ req , rettype , url , verify = self ._verify , ** kwargs )
371373 r .close ()
372374 # There are some error codes that the specification says that they
373375 # shouldn't be retried
@@ -389,7 +391,10 @@ def _request_retry(self, req, url, rettype='json', **kwargs):
389391 if rettype == 'content' :
390392 return r .content
391393 else :
392- raise ValueError ("return type rettype='%s' cannot be understand. Choose from 'json' (default) or 'content!" % rettype )
394+ raise ValueError (
395+ ("return type rettype='%s' cannot be "
396+ "understand. Choose from 'json' (default) "
397+ "or 'content!" ) % rettype )
393398 except ValueError :
394399 return None
395400 stime = randint (MIN_TIME_SLEEP , MAX_TIME_SLEEP )
@@ -420,7 +425,8 @@ def get(self, url, rettype='json', **kwargs):
420425 The JSON response from the server
421426 """
422427 logger .debug ('Entered QiitaClient.get()' )
423- return self ._request_retry (self ._session .get , url , rettype = rettype , ** kwargs )
428+ return self ._request_retry (
429+ self ._session .get , url , rettype = rettype , ** kwargs )
424430
425431 def post (self , url , ** kwargs ):
426432 """Execute a post request against the Qiita server
@@ -438,7 +444,8 @@ def post(self, url, **kwargs):
438444 The JSON response from the server
439445 """
440446 logger .debug ('Entered QiitaClient.post(%s)' % url )
441- return self ._request_retry (self ._session .post , url , rettype = 'json' , ** kwargs )
447+ return self ._request_retry (
448+ self ._session .post , url , rettype = 'json' , ** kwargs )
442449
443450 def patch (self , url , op , path , value = None , from_p = None , ** kwargs ):
444451 """Executes a JSON patch request against the Qiita server
@@ -497,7 +504,8 @@ def patch(self, url, op, path, value=None, from_p=None, **kwargs):
497504 # we made sure that data is correctly formatted here
498505 kwargs ['data' ] = data
499506
500- return self ._request_retry (self ._session .patch , url , rettype = 'json' , ** kwargs )
507+ return self ._request_retry (
508+ self ._session .patch , url , rettype = 'json' , ** kwargs )
501509
502510 # The functions are shortcuts for common functionality that all plugins
503511 # need to implement.
@@ -520,7 +528,8 @@ def http_patch(self, url, **kwargs):
520528 The JSON response from the server
521529 """
522530 logger .debug ('Entered QiitaClient.http_patch()' )
523- return self ._request_retry (self ._session .patch , url , rettype = 'json' , ** kwargs )
531+ return self ._request_retry (
532+ self ._session .patch , url , rettype = 'json' , ** kwargs )
524533
525534 def start_heartbeat (self , job_id ):
526535 """Create and start a thread that would send heartbeats to the server
@@ -741,7 +750,9 @@ def fetch_file_from_central(self, filepath):
741750 logger .debug ('Requesting file %s from qiita server.' % filepath )
742751
743752 # actual call to Qiita central to obtain file content
744- content = self .get ('/cloud/fetch_file_from_central/' + filepath , rettype = 'content' )
753+ content = self .get (
754+ '/cloud/fetch_file_from_central/' + filepath ,
755+ rettype = 'content' )
745756
746757 # create necessary directory locally
747758 os .makedirs (os .path .dirname (filepath ), exist_ok = True )
@@ -752,7 +763,9 @@ def fetch_file_from_central(self, filepath):
752763
753764 return filepath
754765
755- raise ValueError ("File communication protocol '%s' as defined in plugins configuration is NOT defined." % self ._plugincoupling )
766+ raise ValueError (
767+ ("File communication protocol '%s' as defined in plugins "
768+ "configuration is NOT defined." ) % self ._plugincoupling )
756769
757770 def push_file_to_central (self , filepath ):
758771 if self ._plugincoupling == 'filesystem' :
@@ -761,9 +774,12 @@ def push_file_to_central(self, filepath):
761774 if self ._plugincoupling == 'https' :
762775 logger .debug ('Submitting file %s to qiita server.' % filepath )
763776
764- self .post ('/cloud/push_file_to_central/' ,
777+ self .post (
778+ '/cloud/push_file_to_central/' ,
765779 files = {os .path .dirname (filepath ): open (filepath , 'rb' )})
766780
767781 return filepath
768782
769- raise ValueError ("File communication protocol '%s' as defined in plugins configuration is NOT defined." % self ._plugincoupling )
783+ raise ValueError (
784+ ("File communication protocol '%s' as defined in plugins "
785+ "configuration is NOT defined." ) % self ._plugincoupling )
0 commit comments