| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0b71ba4 commit d187925
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -225,8 +225,8 @@ order options. At the time of writing, only ``order_by="id"`` works. | |||
| 225 | 225 | ||
| 226 | 226 | .. code-block:: python | |
| 227 | 227 | ||
| 228 | - gl = gitlab.Gitlab(url, token, pagination="keyset", per_page=100) | ||
| 229 | - gl.projects.list(order_by="id") | ||
| 228 | + gl = gitlab.Gitlab(url, token, pagination="keyset", order_by="id", per_page=100) | ||
| 229 | + gl.projects.list() | ||
| 230 | 230 | ||
| 231 | 231 | Reference: | |
| 232 | 232 | https://docs.gitlab.com/ce/api/README.html#keyset-based-pagination | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -70,6 +70,7 @@ class Gitlab(object): | |||
| 70 | 70 | http_password (str): Password for HTTP authentication | |
| 71 | 71 | api_version (str): Gitlab API version to use (support for 4 only) | |
| 72 | 72 | pagination (str): Can be set to 'keyset' to use keyset pagination | |
| 73 | + order_by (str): Set order_by globally | ||
| 73 | 74 | """ | |
| 74 | 75 | ||
| 75 | 76 | def __init__( | |
@@ -86,6 +87,7 @@ def __init__( | |||
| 86 | 87 | session=None, | |
| 87 | 88 | per_page=None, | |
| 88 | 89 | pagination=None, | |
| 90 | + order_by=None, | ||
| 89 | 91 | ): | |
| 90 | 92 | ||
| 91 | 93 | self._api_version = str(api_version) | |
@@ -112,6 +114,7 @@ def __init__( | |||
| 112 | 114 | ||
| 113 | 115 | self.per_page = per_page | |
| 114 | 116 | self.pagination = pagination | |
| 117 | + self.order_by = order_by | ||
| 115 | 118 | ||
| 116 | 119 | objects = importlib.import_module("gitlab.v%s.objects" % self._api_version) | |
| 117 | 120 | self._objects = objects | |
@@ -204,6 +207,7 @@ def from_config(cls, gitlab_id=None, config_files=None): | |||
| 204 | 207 | api_version=config.api_version, | |
| 205 | 208 | per_page=config.per_page, | |
| 206 | 209 | pagination=config.pagination, | |
| 210 | + order_by=config.order_by, | ||
| 207 | 211 | ) | |
| 208 | 212 | ||
| 209 | 213 | def auth(self): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,3 +169,9 @@ def __init__(self, gitlab_id=None, config_files=None): | |||
| 169 | 169 | self.pagination = self._config.get(self.gitlab_id, "pagination") | |
| 170 | 170 | except Exception: | |
| 171 | 171 | pass | |
| 172 | + | ||
| 173 | + self.order_by = None | ||
| 174 | + try: | ||
| 175 | + self.order_by = self._config.get(self.gitlab_id, "order_by") | ||
| 176 | + except Exception: | ||
| 177 | + pass | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,6 +124,9 @@ def list(self, **kwargs): | |||
| 124 | 124 | if self.gitlab.pagination: | |
| 125 | 125 | data.setdefault("pagination", self.gitlab.pagination) | |
| 126 | 126 | ||
| 127 | + if self.gitlab.order_by: | ||
| 128 | + data.setdefault("order_by", self.gitlab.order_by) | ||
| 129 | + | ||
| 127 | 130 | # We get the attributes that need some special transformation | |
| 128 | 131 | types = getattr(self, "_types", {}) | |
| 129 | 132 | if types: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments