1818from __future__ import print_function
1919from __future__ import division
2020from __future__ import absolute_import
21- from itertools import chain
21+ import itertools
2222import json
2323import sys
2424import warnings
@@ -179,13 +179,13 @@ def credentials_auth(self):
179179 else :
180180 _raiseErrorFromResponse (r , GitlabAuthenticationError )
181181
182- self .setToken (self .user .private_token )
182+ self .set_token (self .user .private_token )
183183
184184 def token_auth (self ):
185185 self .user = CurrentUser (self )
186186
187187 def setUrl (self , url ):
188- """Updates the gitlab URL"""
188+ """Updates the gitlab URL. """
189189 self ._url = '%s/api/v3' % url
190190
191191 def constructUrl (self , id_ , obj , parameters ):
@@ -205,27 +205,28 @@ def _createHeaders(self, content_type=None, headers={}):
205205 return request_headers
206206
207207 def setToken (self , token ):
208- """(DEPRECATED) Sets the private token for authentication"""
208+ """(DEPRECATED) Sets the private token for authentication. """
209209 warnings .warn ("setToken is deprecated, use set_token instead" ,
210210 DeprecationWarning )
211211 self .set_token (token )
212212
213213 def set_token (self , token ):
214- """Sets the private token for authentication"""
214+ """Sets the private token for authentication. """
215215 self .private_token = token if token else None
216216 if token :
217217 self .headers ["PRIVATE-TOKEN" ] = token
218218 elif "PRIVATE-TOKEN" in self .headers :
219219 del self .headers ["PRIVATE-TOKEN" ]
220220
221221 def setCredentials (self , email , password ):
222- """(DEPRECATED) Sets the email/login and password for authentication"""
223- warnings .warn ("setToken is deprecated, use set_credentials instead" ,
222+ """(DEPRECATED) Sets the login and password for authentication."""
223+ warnings .warn ("setCredential is deprecated, use set_credentials "
224+ "instead" ,
224225 DeprecationWarning )
225226 self .set_credentials (email , password )
226227
227228 def set_credentials (self , email , password ):
228- """Sets the email/login and password for authentication"""
229+ """Sets the email/login and password for authentication. """
229230 self .email = email
230231 self .password = password
231232
@@ -300,8 +301,8 @@ def _raw_delete(self, path, content_type=None, **kwargs):
300301
301302 def list (self , obj_class , ** kwargs ):
302303 missing = []
303- for k in chain (obj_class .requiredUrlAttrs ,
304- obj_class .requiredListAttrs ):
304+ for k in itertools . chain (obj_class .requiredUrlAttrs ,
305+ obj_class .requiredListAttrs ):
305306 if k not in kwargs :
306307 missing .append (k )
307308 if missing :
@@ -348,8 +349,8 @@ def list(self, obj_class, **kwargs):
348349
349350 def get (self , obj_class , id = None , ** kwargs ):
350351 missing = []
351- for k in chain (obj_class .requiredUrlAttrs ,
352- obj_class .requiredGetAttrs ):
352+ for k in itertools . chain (obj_class .requiredUrlAttrs ,
353+ obj_class .requiredGetAttrs ):
353354 if k not in kwargs :
354355 missing .append (k )
355356 if missing :
@@ -381,7 +382,8 @@ def delete(self, obj, **kwargs):
381382 params = obj .__dict__ .copy ()
382383 params .update (kwargs )
383384 missing = []
384- for k in chain (obj .requiredUrlAttrs , obj .requiredDeleteAttrs ):
385+ for k in itertools .chain (obj .requiredUrlAttrs ,
386+ obj .requiredDeleteAttrs ):
385387 if k not in params :
386388 missing .append (k )
387389 if missing :
@@ -415,7 +417,8 @@ def create(self, obj, **kwargs):
415417 params = obj .__dict__ .copy ()
416418 params .update (kwargs )
417419 missing = []
418- for k in chain (obj .requiredUrlAttrs , obj .requiredCreateAttrs ):
420+ for k in itertools .chain (obj .requiredUrlAttrs ,
421+ obj .requiredCreateAttrs ):
419422 if k not in params :
420423 missing .append (k )
421424 if missing :
@@ -446,7 +449,8 @@ def update(self, obj, **kwargs):
446449 params = obj .__dict__ .copy ()
447450 params .update (kwargs )
448451 missing = []
449- for k in chain (obj .requiredUrlAttrs , obj .requiredCreateAttrs ):
452+ for k in itertools .chain (obj .requiredUrlAttrs ,
453+ obj .requiredCreateAttrs ):
450454 if k not in params :
451455 missing .append (k )
452456 if missing :
@@ -642,8 +646,8 @@ class GitlabObject(object):
642646
643647 def _dataForGitlab (self , extra_parameters = {}):
644648 data = {}
645- for attribute in chain (self .requiredCreateAttrs ,
646- self .optionalCreateAttrs ):
649+ for attribute in itertools . chain (self .requiredCreateAttrs ,
650+ self .optionalCreateAttrs ):
647651 if hasattr (self , attribute ):
648652 data [attribute ] = getattr (self , attribute )
649653
@@ -719,8 +723,8 @@ def __init__(self, gl, data=None, **kwargs):
719723 self ._created = False
720724 self .gitlab = gl
721725
722- if data is None or isinstance (data , six .integer_types ) or \
723- isinstance (data , six .string_types ):
726+ if ( data is None or isinstance (data , six .integer_types ) or
727+ isinstance (data , six .string_types ) ):
724728 if not self .canGet :
725729 raise NotImplementedError
726730 data = self .gitlab .get (self .__class__ , data , ** kwargs )
@@ -938,8 +942,8 @@ def diff(self, **kwargs):
938942 _raiseErrorFromResponse (r , GitlabGetError )
939943
940944 def blob (self , filepath , ** kwargs ):
941- url = '/projects/%(project_id)s/repository/blobs/%(commit_id)s' % \
942- {'project_id' : self .project_id , 'commit_id' : self .id }
945+ url = ( '/projects/%(project_id)s/repository/blobs/%(commit_id)s' %
946+ {'project_id' : self .project_id , 'commit_id' : self .id })
943947 url += '?filepath=%s' % filepath
944948 r = self .gitlab ._raw_get (url , ** kwargs )
945949 if r .status_code == 200 :
@@ -1115,8 +1119,8 @@ class ProjectSnippet(GitlabObject):
11151119 shortPrintAttr = 'title'
11161120
11171121 def Content (self , ** kwargs ):
1118- url = "/projects/%(project_id)s/snippets/%(snippet_id)s/raw" % \
1119- {'project_id' : self .project_id , 'snippet_id' : self .id }
1122+ url = ( "/projects/%(project_id)s/snippets/%(snippet_id)s/raw" %
1123+ {'project_id' : self .project_id , 'snippet_id' : self .id })
11201124 r = self .gitlab ._raw_get (url , ** kwargs )
11211125
11221126 if r .status_code == 200 :
@@ -1271,24 +1275,24 @@ def create_file(self, path, branch, content, message, **kwargs):
12711275 GitlabConnectionError: Connection to GitLab-server failed
12721276 """
12731277 url = "/projects/%s/repository/files" % self .id
1274- url += "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % \
1275- (path , branch , content , message )
1278+ url += ( "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" %
1279+ (path , branch , content , message ) )
12761280 r = self .gitlab ._raw_post (url , data = None , content_type = None , ** kwargs )
12771281 if r .status_code != 201 :
12781282 _raiseErrorFromResponse (r , GitlabCreateError )
12791283
12801284 def update_file (self , path , branch , content , message , ** kwargs ):
12811285 url = "/projects/%s/repository/files" % self .id
1282- url += "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % \
1283- (path , branch , content , message )
1286+ url += ( "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" %
1287+ (path , branch , content , message ) )
12841288 r = self .gitlab ._raw_put (url , data = None , content_type = None , ** kwargs )
12851289 if r .status_code != 200 :
12861290 _raiseErrorFromResponse (r , GitlabUpdateError )
12871291
12881292 def delete_file (self , path , branch , message , ** kwargs ):
12891293 url = "/projects/%s/repository/files" % self .id
1290- url += "?file_path=%s&branch_name=%s&commit_message=%s" % \
1291- (path , branch , message )
1294+ url += ( "?file_path=%s&branch_name=%s&commit_message=%s" %
1295+ (path , branch , message ) )
12921296 r = self .gitlab ._raw_delete (url , ** kwargs )
12931297 if r .status_code != 200 :
12941298 _raiseErrorFromResponse (r , GitlabDeleteError )
0 commit comments