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

Commit20fdbe8

Browse files
author
Gauvain Pocentek
authored
Merge pull request#169 from hakkeroid/allow-iid-parameter-to-request-distinct-objects
Convert response list to single data source for iid requests
2 parents9da5d69 +23b5b6e commit20fdbe8

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎gitlab/objects.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,22 @@ def __init__(self, gl, data=None, **kwargs):
378378
data=self.gitlab.get(self.__class__,data,**kwargs)
379379
self._from_api=True
380380

381+
# the API returned a list because custom kwargs where used
382+
# instead of the id to request an object. Usually parameters
383+
# other than an id return ambiguous results. However in the
384+
# gitlab universe iids together with a project_id are
385+
# unambiguous for merge requests and issues, too.
386+
# So if there is only one element we can use it as our data
387+
# source.
388+
if'iid'inkwargsandisinstance(data,list):
389+
iflen(data)<1:
390+
raiseGitlabGetError('Not found')
391+
eliflen(data)==1:
392+
data=data[0]
393+
else:
394+
raiseGitlabGetError('Impossible! You found multiple'
395+
' elements with the same iid.')
396+
381397
self._set_from_dict(data,**kwargs)
382398

383399
ifkwargs:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp