diff options
Diffstat (limited to 'gitlab')
-rw-r--r-- | gitlab/__init__.py | 4 | ||||
-rw-r--r-- | gitlab/config.py | 6 | ||||
-rw-r--r-- | gitlab/mixins.py | 3 |
3 files changed, 13 insertions, 0 deletions
diff --git a/gitlab/__init__.py b/gitlab/__init__.py index 166e00f..85fc5e0 100644 --- a/gitlab/__init__.py +++ b/gitlab/__init__.py @@ -70,6 +70,7 @@ class Gitlab(object): http_password (str): Password for HTTP authentication api_version (str): Gitlab API version to use (support for 4 only) pagination (str): Can be set to 'keyset' to use keyset pagination + order_by (str): Set order_by globally """ def __init__( @@ -86,6 +87,7 @@ class Gitlab(object): session=None, per_page=None, pagination=None, + order_by=None, ): self._api_version = str(api_version) @@ -112,6 +114,7 @@ class Gitlab(object): self.per_page = per_page self.pagination = pagination + self.order_by = order_by objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) self._objects = objects @@ -204,6 +207,7 @@ class Gitlab(object): api_version=config.api_version, per_page=config.per_page, pagination=config.pagination, + order_by=config.order_by, ) def auth(self): diff --git a/gitlab/config.py b/gitlab/config.py index 95a1245..2272dd3 100644 --- a/gitlab/config.py +++ b/gitlab/config.py @@ -169,3 +169,9 @@ class GitlabConfigParser(object): self.pagination = self._config.get(self.gitlab_id, "pagination") except Exception: pass + + self.order_by = None + try: + self.order_by = self._config.get(self.gitlab_id, "order_by") + except Exception: + pass diff --git a/gitlab/mixins.py b/gitlab/mixins.py index 2437a6f..8544499 100644 --- a/gitlab/mixins.py +++ b/gitlab/mixins.py @@ -124,6 +124,9 @@ class ListMixin(object): if self.gitlab.pagination: data.setdefault("pagination", self.gitlab.pagination) + if self.gitlab.order_by: + data.setdefault("order_by", self.gitlab.order_by) + # We get the attributes that need some special transformation types = getattr(self, "_types", {}) if types: |