Skip to content
Snippets Groups Projects
Commit 4c4abae5 authored by Jakob Berger's avatar Jakob Berger :key2: Committed by jakob
Browse files

single object search returns the object directly instead of a list containing only one object

parent c2180f52
No related branches found
No related tags found
No related merge requests found
...@@ -149,17 +149,16 @@ class Gitlab: ...@@ -149,17 +149,16 @@ class Gitlab:
return self._iterate_over_objects(url, __find_single_object_abstract, *args, cache_behaviour=cache_behaviour, return self._iterate_over_objects(url, __find_single_object_abstract, *args, cache_behaviour=cache_behaviour,
print_progress=print_progress) print_progress=print_progress)
def find_objects_by_attributes(self, url: str, attributes=None, print_progress: bool = False, def find_objects_by_attributes(self, url: str, attributes: dict = {}, print_progress: bool = False,
cache_behaviour: CacheBehaviour = CacheBehaviour.ignore) -> list: cache_behaviour: CacheBehaviour = CacheBehaviour.ignore) -> list:
if attributes is None:
attributes = {}
return self._iterate_over_objects(url, self._Filtermethods.filter_page_by_attribute, attributes, return self._iterate_over_objects(url, self._Filtermethods.filter_page_by_attribute, attributes,
cache_behaviour=cache_behaviour, print_progress=print_progress) cache_behaviour=cache_behaviour, print_progress=print_progress)
def find_single_object_by_attributes(self, url: str, attributes: dict, print_progress: bool = False, def find_single_object_by_attributes(self, url: str, attributes: dict, print_progress: bool = False,
cache_behaviour: CacheBehaviour = CacheBehaviour.ignore) -> list: cache_behaviour: CacheBehaviour = CacheBehaviour.ignore) -> object:
return self._find_single_object(url, self._Filtermethods.object_matches_attributes, attributes, result = self._find_single_object(url, self._Filtermethods.object_matches_attributes, attributes,
cache_behaviour=cache_behaviour, print_progress=print_progress) cache_behaviour=cache_behaviour, print_progress=print_progress)
return result[0] if len(result)>0 else None
class _Filtermethods: class _Filtermethods:
@staticmethod @staticmethod
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment