Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0032d46

Browse files
author
Gauvain Pocentek
committed
make the tests pass
1 parent8634a4d commit0032d46

File tree

4 files changed

+218
-122
lines changed

4 files changed

+218
-122
lines changed

‎gitlab/__init__.py

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from __future__importprint_function
1919
from __future__importdivision
2020
from __future__importabsolute_import
21-
fromitertoolsimportchain
21+
importitertools
2222
importjson
2323
importsys
2424
importwarnings
@@ -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
deftoken_auth(self):
185185
self.user=CurrentUser(self)
186186

187187
defsetUrl(self,url):
188-
"""Updates the gitlab URL"""
188+
"""Updates the gitlab URL."""
189189
self._url='%s/api/v3'%url
190190

191191
defconstructUrl(self,id_,obj,parameters):
@@ -205,27 +205,28 @@ def _createHeaders(self, content_type=None, headers={}):
205205
returnrequest_headers
206206

207207
defsetToken(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
defset_token(self,token):
214-
"""Sets the private token for authentication"""
214+
"""Sets the private token for authentication."""
215215
self.private_token=tokeniftokenelseNone
216216
iftoken:
217217
self.headers["PRIVATE-TOKEN"]=token
218218
elif"PRIVATE-TOKEN"inself.headers:
219219
delself.headers["PRIVATE-TOKEN"]
220220

221221
defsetCredentials(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
defset_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
deflist(self,obj_class,**kwargs):
302303
missing= []
303-
forkinchain(obj_class.requiredUrlAttrs,
304-
obj_class.requiredListAttrs):
304+
forkinitertools.chain(obj_class.requiredUrlAttrs,
305+
obj_class.requiredListAttrs):
305306
ifknotinkwargs:
306307
missing.append(k)
307308
ifmissing:
@@ -348,8 +349,8 @@ def list(self, obj_class, **kwargs):
348349

349350
defget(self,obj_class,id=None,**kwargs):
350351
missing= []
351-
forkinchain(obj_class.requiredUrlAttrs,
352-
obj_class.requiredGetAttrs):
352+
forkinitertools.chain(obj_class.requiredUrlAttrs,
353+
obj_class.requiredGetAttrs):
353354
ifknotinkwargs:
354355
missing.append(k)
355356
ifmissing:
@@ -381,7 +382,8 @@ def delete(self, obj, **kwargs):
381382
params=obj.__dict__.copy()
382383
params.update(kwargs)
383384
missing= []
384-
forkinchain(obj.requiredUrlAttrs,obj.requiredDeleteAttrs):
385+
forkinitertools.chain(obj.requiredUrlAttrs,
386+
obj.requiredDeleteAttrs):
385387
ifknotinparams:
386388
missing.append(k)
387389
ifmissing:
@@ -415,7 +417,8 @@ def create(self, obj, **kwargs):
415417
params=obj.__dict__.copy()
416418
params.update(kwargs)
417419
missing= []
418-
forkinchain(obj.requiredUrlAttrs,obj.requiredCreateAttrs):
420+
forkinitertools.chain(obj.requiredUrlAttrs,
421+
obj.requiredCreateAttrs):
419422
ifknotinparams:
420423
missing.append(k)
421424
ifmissing:
@@ -446,7 +449,8 @@ def update(self, obj, **kwargs):
446449
params=obj.__dict__.copy()
447450
params.update(kwargs)
448451
missing= []
449-
forkinchain(obj.requiredUrlAttrs,obj.requiredCreateAttrs):
452+
forkinitertools.chain(obj.requiredUrlAttrs,
453+
obj.requiredCreateAttrs):
450454
ifknotinparams:
451455
missing.append(k)
452456
ifmissing:
@@ -642,8 +646,8 @@ class GitlabObject(object):
642646

643647
def_dataForGitlab(self,extra_parameters={}):
644648
data= {}
645-
forattributeinchain(self.requiredCreateAttrs,
646-
self.optionalCreateAttrs):
649+
forattributeinitertools.chain(self.requiredCreateAttrs,
650+
self.optionalCreateAttrs):
647651
ifhasattr(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-
ifdataisNoneorisinstance(data,six.integer_types)or\
723-
isinstance(data,six.string_types):
726+
if(dataisNoneorisinstance(data,six.integer_types)or
727+
isinstance(data,six.string_types)):
724728
ifnotself.canGet:
725729
raiseNotImplementedError
726730
data=self.gitlab.get(self.__class__,data,**kwargs)
@@ -938,8 +942,8 @@ def diff(self, **kwargs):
938942
_raiseErrorFromResponse(r,GitlabGetError)
939943

940944
defblob(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
ifr.status_code==200:
@@ -1115,8 +1119,8 @@ class ProjectSnippet(GitlabObject):
11151119
shortPrintAttr='title'
11161120

11171121
defContent(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
ifr.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
ifr.status_code!=201:
12781282
_raiseErrorFromResponse(r,GitlabCreateError)
12791283

12801284
defupdate_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
ifr.status_code!=200:
12861290
_raiseErrorFromResponse(r,GitlabUpdateError)
12871291

12881292
defdelete_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
ifr.status_code!=200:
12941298
_raiseErrorFromResponse(r,GitlabDeleteError)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp