python-gerrit-api 3.0.9__tar.gz → 3.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. {python_gerrit_api-3.0.9/python_gerrit_api.egg-info → python_gerrit_api-3.1.0}/PKG-INFO +14 -2
  2. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/__init__.py +3 -1
  3. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/accounts/account.py +3 -2
  4. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/accounts/accounts.py +6 -3
  5. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/accounts/emails.py +4 -3
  6. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/accounts/gpg_keys.py +4 -3
  7. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/accounts/ssh_keys.py +4 -3
  8. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/base.py +21 -10
  9. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/change.py +3 -2
  10. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/changes.py +2 -1
  11. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/comments.py +4 -3
  12. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/drafts.py +4 -3
  13. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/edit.py +4 -3
  14. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/files.py +4 -3
  15. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/messages.py +4 -3
  16. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/reviewers.py +4 -3
  17. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/revision.py +11 -6
  18. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/config/caches.py +4 -2
  19. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/config/config.py +2 -1
  20. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/config/tasks.py +4 -2
  21. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/groups/group.py +3 -2
  22. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/groups/groups.py +4 -3
  23. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/groups/members.py +2 -2
  24. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/groups/subgroups.py +2 -1
  25. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/plugins/plugins.py +3 -2
  26. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/branches.py +4 -3
  27. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/commit.py +3 -2
  28. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/dashboards.py +4 -3
  29. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/labels.py +4 -3
  30. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/project.py +3 -2
  31. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/projects.py +4 -2
  32. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/tags.py +4 -3
  33. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/webhooks.py +4 -3
  34. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/utils/common.py +3 -1
  35. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/utils/gerritbase.py +6 -3
  36. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gitiles/__init__.py +2 -0
  37. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0/python_gerrit_api.egg-info}/PKG-INFO +14 -2
  38. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/SOURCES.txt +1 -0
  39. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/setup.py +1 -0
  40. python_gerrit_api-3.1.0/tests/test_accounts.py +364 -0
  41. python_gerrit_api-3.1.0/tests/test_changes.py +480 -0
  42. python_gerrit_api-3.1.0/tests/test_config_and_plugins.py +290 -0
  43. python_gerrit_api-3.1.0/tests/test_gitiles.py +122 -0
  44. python_gerrit_api-3.1.0/tests/test_groups.py +261 -0
  45. python_gerrit_api-3.1.0/tests/test_projects.py +475 -0
  46. python_gerrit_api-3.1.0/tests/test_revision.py +381 -0
  47. python_gerrit_api-3.0.9/tests/test_accounts.py +0 -283
  48. python_gerrit_api-3.0.9/tests/test_changes.py +0 -177
  49. python_gerrit_api-3.0.9/tests/test_gitiles.py +0 -40
  50. python_gerrit_api-3.0.9/tests/test_groups.py +0 -126
  51. python_gerrit_api-3.0.9/tests/test_projects.py +0 -340
  52. python_gerrit_api-3.0.9/tests/test_revision.py +0 -167
  53. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/LICENSE +0 -0
  54. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/MANIFEST.in +0 -0
  55. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/README.rst +0 -0
  56. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/accounts/__init__.py +0 -0
  57. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/changes/__init__.py +0 -0
  58. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/config/__init__.py +0 -0
  59. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/groups/__init__.py +0 -0
  60. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/plugins/__init__.py +0 -0
  61. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/projects/__init__.py +0 -0
  62. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/utils/__init__.py +0 -0
  63. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/utils/exceptions.py +0 -0
  64. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gerrit/utils/requester.py +0 -0
  65. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/gitiles/base.py +0 -0
  66. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/dependency_links.txt +0 -0
  67. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/requires.txt +0 -0
  68. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/top_level.txt +0 -0
  69. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/requirements.txt +0 -0
  70. {python_gerrit_api-3.0.9 → python_gerrit_api-3.1.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: python-gerrit-api
3
- Version: 3.0.9
3
+ Version: 3.1.0
4
4
  Summary: Python wrapper for the Gerrit REST API.
5
5
  Home-page: https://github.com/shijl0925/python-gerrit-api
6
6
  Author: Jialiang Shi
@@ -20,8 +20,20 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Classifier: Topic :: Software Development
23
+ Description-Content-Type: text/x-rst
23
24
  License-File: LICENSE
24
25
  Requires-Dist: requests
26
+ Dynamic: author
27
+ Dynamic: author-email
28
+ Dynamic: classifier
29
+ Dynamic: description
30
+ Dynamic: description-content-type
31
+ Dynamic: home-page
32
+ Dynamic: keywords
33
+ Dynamic: license
34
+ Dynamic: license-file
35
+ Dynamic: requires-dist
36
+ Dynamic: summary
25
37
 
26
38
  Project description
27
39
  ===================
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
- __version__ = "3.0.9"
4
+ __version__ = "3.1.0"
5
5
 
6
6
  from gerrit.base import GerritClient
7
+
8
+ __all__ = ["GerritClient"]
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
4
5
  from gerrit.utils.gerritbase import GerritBase
5
6
  from gerrit.accounts.emails import GerritAccountEmails
6
7
  from gerrit.accounts.ssh_keys import GerritAccountSSHKeys
@@ -8,11 +9,11 @@ from gerrit.accounts.gpg_keys import GerritAccountGPGKeys
8
9
 
9
10
 
10
11
  class GerritAccount(GerritBase):
11
- def __init__(self, account, gerrit):
12
+ def __init__(self, account, gerrit: GerritClient):
12
13
  self.account = account
13
14
  self.gerrit = gerrit
14
15
  self.endpoint = f"/accounts/{self.account}"
15
- super().__init__(self)
16
+ super().__init__()
16
17
 
17
18
  def __str__(self):
18
19
  return str(self.account)
@@ -3,7 +3,7 @@
3
3
  # @Author: Jialiang Shi
4
4
  import logging
5
5
  import requests
6
- from gerrit.accounts.account import GerritAccount
6
+ from gerrit import GerritClient
7
7
  from gerrit.utils.exceptions import (
8
8
  AccountNotFoundError,
9
9
  AccountAlreadyExistsError,
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
15
15
 
16
16
 
17
17
  class GerritAccounts:
18
- def __init__(self, gerrit):
18
+ def __init__(self, gerrit: GerritClient):
19
19
  self.gerrit = gerrit
20
20
  self.endpoint = "/accounts"
21
21
 
@@ -50,7 +50,6 @@ class GerritAccounts:
50
50
  None,
51
51
  ["DETAILS" if detailed else None, "ALL_EMAILS" if all_emails else None],
52
52
  )
53
- # option = None if not option else option
54
53
  params = {
55
54
  k: v for k, v in (("n", limit), ("S", skip), ("o", option)) if v is not None
56
55
  }
@@ -69,11 +68,15 @@ class GerritAccounts:
69
68
  :param account: username or email or _account_id or 'self'
70
69
  :return:
71
70
  """
71
+ from gerrit.accounts.account import GerritAccount
72
+
72
73
  try:
73
74
  endpoint = self.endpoint + f"/{account}/"
74
75
  result = self.gerrit.get(endpoint)
75
76
 
76
77
  account_ = result.get("_account_id")
78
+ if account_ is None:
79
+ raise ValueError("Account ID not found")
77
80
  return GerritAccount(account=account_, gerrit=self.gerrit)
78
81
  except requests.exceptions.HTTPError as error:
79
82
  if error.response.status_code == 404:
@@ -3,6 +3,7 @@
3
3
  # @Author: Jialiang Shi
4
4
  import logging
5
5
  import requests
6
+ from gerrit import GerritClient
6
7
  from gerrit.utils.gerritbase import GerritBase
7
8
  from gerrit.utils.exceptions import (
8
9
  AccountEmailNotFoundError,
@@ -15,12 +16,12 @@ logger = logging.getLogger(__name__)
15
16
 
16
17
 
17
18
  class GerritAccountEmail(GerritBase):
18
- def __init__(self, email, account, gerrit):
19
+ def __init__(self, email, account, gerrit: GerritClient):
19
20
  self.email = email
20
21
  self.account = account
21
22
  self.gerrit = gerrit
22
23
  self.endpoint = f"/accounts/{self.account}/emails/{self.email}"
23
- super().__init__(self)
24
+ super().__init__()
24
25
 
25
26
  def __str__(self):
26
27
  return self.email
@@ -43,7 +44,7 @@ class GerritAccountEmail(GerritBase):
43
44
 
44
45
 
45
46
  class GerritAccountEmails:
46
- def __init__(self, account, gerrit):
47
+ def __init__(self, account, gerrit: GerritClient):
47
48
  self.account = account
48
49
  self.gerrit = gerrit
49
50
  self.endpoint = f"/accounts/{self.account}/emails"
@@ -3,6 +3,7 @@
3
3
  # @Author: Jialiang Shi
4
4
  import logging
5
5
  import requests
6
+ from gerrit import GerritClient
6
7
  from gerrit.utils.gerritbase import GerritBase
7
8
  from gerrit.utils.exceptions import GPGKeyNotFoundError, GerritAPIException
8
9
 
@@ -10,12 +11,12 @@ logger = logging.getLogger(__name__)
10
11
 
11
12
 
12
13
  class GerritAccountGPGKey(GerritBase):
13
- def __init__(self, id, account, gerrit):
14
+ def __init__(self, id, account, gerrit: GerritClient):
14
15
  self.id = id
15
16
  self.account = account
16
17
  self.gerrit = gerrit
17
18
  self.endpoint = f"/accounts/{self.account}/gpgkeys/{self.id}"
18
- super().__init__(self)
19
+ super().__init__()
19
20
 
20
21
  def __str__(self):
21
22
  return self.id
@@ -30,7 +31,7 @@ class GerritAccountGPGKey(GerritBase):
30
31
 
31
32
 
32
33
  class GerritAccountGPGKeys:
33
- def __init__(self, account, gerrit):
34
+ def __init__(self, account, gerrit: GerritClient):
34
35
  self.account = account
35
36
  self.gerrit = gerrit
36
37
  self.endpoint = f"/accounts/{self.account}/gpgkeys"
@@ -3,6 +3,7 @@
3
3
  # @Author: Jialiang Shi
4
4
  import logging
5
5
  import requests
6
+ from gerrit import GerritClient
6
7
  from gerrit.utils.gerritbase import GerritBase
7
8
  from gerrit.utils.exceptions import SSHKeyNotFoundError, GerritAPIException
8
9
 
@@ -10,12 +11,12 @@ logger = logging.getLogger(__name__)
10
11
 
11
12
 
12
13
  class GerritAccountSSHKey(GerritBase):
13
- def __init__(self, seq, account, gerrit):
14
+ def __init__(self, seq, account, gerrit: GerritClient):
14
15
  self.seq = seq
15
16
  self.account = account
16
17
  self.gerrit = gerrit
17
18
  self.endpoint = f"/accounts/{self.account}/sshkeys"
18
- super().__init__(self)
19
+ super().__init__()
19
20
 
20
21
  def __str__(self):
21
22
  return str(self.seq)
@@ -30,7 +31,7 @@ class GerritAccountSSHKey(GerritBase):
30
31
 
31
32
 
32
33
  class GerritAccountSSHKeys:
33
- def __init__(self, account, gerrit):
34
+ def __init__(self, account, gerrit: GerritClient):
34
35
  self.account = account
35
36
  self.gerrit = gerrit
36
37
  self.endpoint = f"/accounts/{self.account}/sshkeys"
@@ -1,17 +1,14 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ import logging
4
5
  import netrc
5
6
  import requests
6
7
  from requests.adapters import HTTPAdapter
7
8
  from gerrit.utils.requester import Requester
8
9
  from gerrit.utils.common import decode_response, strip_trailing_slash
9
- from gerrit.config.config import GerritConfig
10
- from gerrit.projects.projects import GerritProjects
11
- from gerrit.accounts.accounts import GerritAccounts
12
- from gerrit.groups.groups import GerritGroups
13
- from gerrit.plugins.plugins import GerritPlugins
14
- from gerrit.changes.changes import GerritChanges
10
+
11
+ logger = logging.getLogger(__name__)
15
12
 
16
13
 
17
14
  class GerritClient:
@@ -107,6 +104,7 @@ class GerritClient:
107
104
 
108
105
  :return:
109
106
  """
107
+ from gerrit.config.config import GerritConfig
110
108
  return GerritConfig(gerrit=self)
111
109
 
112
110
  @property
@@ -115,6 +113,7 @@ class GerritClient:
115
113
  Project related REST APIs
116
114
  :return:
117
115
  """
116
+ from gerrit.projects.projects import GerritProjects
118
117
  return GerritProjects(gerrit=self)
119
118
 
120
119
  @property
@@ -124,6 +123,7 @@ class GerritClient:
124
123
 
125
124
  :return:
126
125
  """
126
+ from gerrit.changes.changes import GerritChanges
127
127
  return GerritChanges(gerrit=self)
128
128
 
129
129
  @property
@@ -133,6 +133,7 @@ class GerritClient:
133
133
 
134
134
  :return:
135
135
  """
136
+ from gerrit.accounts.accounts import GerritAccounts
136
137
  return GerritAccounts(gerrit=self)
137
138
 
138
139
  @property
@@ -142,6 +143,7 @@ class GerritClient:
142
143
 
143
144
  :return:
144
145
  """
146
+ from gerrit.groups.groups import GerritGroups
145
147
  return GerritGroups(gerrit=self)
146
148
 
147
149
  @property
@@ -151,6 +153,7 @@ class GerritClient:
151
153
 
152
154
  :return:
153
155
  """
156
+ from gerrit.plugins.plugins import GerritPlugins
154
157
  return GerritPlugins(gerrit=self)
155
158
 
156
159
  @property
@@ -178,7 +181,9 @@ class GerritClient:
178
181
  :param endpoint: The endpoint to send to.
179
182
  :return:
180
183
  """
181
- response = self.requester.get(self.get_endpoint_url(endpoint), **kwargs)
184
+ url = self.get_endpoint_url(endpoint)
185
+ logger.debug("Sending GET request to %s", url)
186
+ response = self.requester.get(url, **kwargs)
182
187
  result = decode_response(response)
183
188
  return result
184
189
 
@@ -189,7 +194,9 @@ class GerritClient:
189
194
  :param endpoint: The endpoint to send to.
190
195
  :return:
191
196
  """
192
- response = self.requester.post(self.get_endpoint_url(endpoint), **kwargs)
197
+ url = self.get_endpoint_url(endpoint)
198
+ logger.debug("Sending POST request to %s", url)
199
+ response = self.requester.post(url, **kwargs)
193
200
  result = decode_response(response)
194
201
  return result
195
202
 
@@ -200,7 +207,9 @@ class GerritClient:
200
207
  :param endpoint: The endpoint to send to.
201
208
  :return:
202
209
  """
203
- response = self.requester.put(self.get_endpoint_url(endpoint), **kwargs)
210
+ url = self.get_endpoint_url(endpoint)
211
+ logger.debug("Sending PUT request to %s", url)
212
+ response = self.requester.put(url, **kwargs)
204
213
  result = decode_response(response)
205
214
  return result
206
215
 
@@ -211,4 +220,6 @@ class GerritClient:
211
220
  :param endpoint: The endpoint to send to.
212
221
  :return:
213
222
  """
214
- self.requester.delete(self.get_endpoint_url(endpoint))
223
+ url = self.get_endpoint_url(endpoint)
224
+ logger.debug("Sending DELETE request to %s", url)
225
+ self.requester.delete(url)
@@ -2,6 +2,7 @@
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
4
  from typing import Dict
5
+ from gerrit import GerritClient
5
6
  from gerrit.utils.gerritbase import GerritBase
6
7
  from gerrit.changes.reviewers import GerritChangeReviewers
7
8
  from gerrit.changes.revision import GerritChangeRevision
@@ -11,11 +12,11 @@ from gerrit.utils.exceptions import ChangeEditNotFoundError
11
12
 
12
13
 
13
14
  class GerritChange(GerritBase):
14
- def __init__(self, id: str, gerrit):
15
+ def __init__(self, id: str, gerrit: GerritClient):
15
16
  self.id = id
16
17
  self.gerrit = gerrit
17
18
  self.endpoint = f"/changes/{self.id}"
18
- super().__init__(self)
19
+ super().__init__()
19
20
 
20
21
  self.revisions: Dict[str, str] = {}
21
22
  self.current_revision_number = 0
@@ -3,6 +3,7 @@
3
3
  # @Author: Jialiang Shi
4
4
  import logging
5
5
  import requests
6
+ from gerrit import GerritClient
6
7
  from gerrit.changes.change import GerritChange
7
8
  from gerrit.utils.exceptions import ChangeNotFoundError, GerritAPIException
8
9
 
@@ -11,7 +12,7 @@ logger = logging.getLogger(__name__)
11
12
 
12
13
 
13
14
  class GerritChanges:
14
- def __init__(self, gerrit):
15
+ def __init__(self, gerrit: GerritClient):
15
16
  self.gerrit = gerrit
16
17
  self.endpoint = "/changes"
17
18
 
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
4
5
  from gerrit.utils.gerritbase import GerritBase
5
6
 
6
7
 
7
8
  class GerritChangeRevisionComment(GerritBase):
8
- def __init__(self, id: str, change: str, revision: str, gerrit):
9
+ def __init__(self, id: str, change: str, revision: str, gerrit: GerritClient):
9
10
  self.id = id
10
11
  self.change = change
11
12
  self.revision = revision
@@ -13,7 +14,7 @@ class GerritChangeRevisionComment(GerritBase):
13
14
  self.endpoint = (
14
15
  f"/changes/{self.change}/revisions/{self.revision}/comments/{self.id}"
15
16
  )
16
- super().__init__(self)
17
+ super().__init__()
17
18
 
18
19
  def __str__(self):
19
20
  return self.id
@@ -52,7 +53,7 @@ class GerritChangeRevisionComment(GerritBase):
52
53
 
53
54
 
54
55
  class GerritChangeRevisionComments:
55
- def __init__(self, change, revision, gerrit):
56
+ def __init__(self, change, revision, gerrit: GerritClient):
56
57
  self.change = change
57
58
  self.revision = revision
58
59
  self.gerrit = gerrit
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
4
5
  from gerrit.utils.gerritbase import GerritBase
5
6
 
6
7
 
7
8
  class GerritChangeRevisionDraft(GerritBase):
8
- def __init__(self, id: str, change: str, revision: str, gerrit):
9
+ def __init__(self, id: str, change: str, revision: str, gerrit: GerritClient):
9
10
  self.id = id
10
11
  self.change = change
11
12
  self.revision = revision
@@ -13,7 +14,7 @@ class GerritChangeRevisionDraft(GerritBase):
13
14
  self.endpoint = (
14
15
  f"/changes/{self.change}/revisions/{self.revision}/drafts/{self.id}"
15
16
  )
16
- super().__init__(self)
17
+ super().__init__()
17
18
 
18
19
  def __str__(self):
19
20
  return self.id
@@ -52,7 +53,7 @@ class GerritChangeRevisionDraft(GerritBase):
52
53
 
53
54
 
54
55
  class GerritChangeRevisionDrafts:
55
- def __init__(self, change, revision, gerrit):
56
+ def __init__(self, change, revision, gerrit: GerritClient):
56
57
  self.change = change
57
58
  self.revision = revision
58
59
  self.gerrit = gerrit
@@ -2,16 +2,17 @@
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
4
  from urllib.parse import quote_plus
5
+ from gerrit import GerritClient
5
6
  from gerrit.utils.gerritbase import GerritBase
6
7
 
7
8
 
8
9
  class GerritChangeEdit(GerritBase):
9
- def __init__(self, change: str, gerrit):
10
+ def __init__(self, change: str, gerrit: GerritClient):
10
11
  self.change = change
11
12
  self.gerrit = gerrit
12
13
  self.endpoint = f"/changes/{self.change}/edit"
13
14
 
14
- super().__init__(self)
15
+ super().__init__()
15
16
 
16
17
  def __str__(self):
17
18
  return f"change {self.change} edit"
@@ -46,7 +47,7 @@ class GerritChangeEdit(GerritBase):
46
47
  self.gerrit.put(
47
48
  self.endpoint + f"/{quote_plus(file)}",
48
49
  data=file_content,
49
- headers={"Content-Type": "plain/text"},
50
+ headers={"Content-Type": "text/plain"},
50
51
  )
51
52
 
52
53
  def restore_file_content(self, file):
@@ -6,6 +6,7 @@ from typing import Optional
6
6
  from base64 import b64decode
7
7
  from urllib.parse import quote_plus
8
8
  import requests
9
+ from gerrit import GerritClient
9
10
  from gerrit.utils.exceptions import (
10
11
  UnknownFile,
11
12
  FileContentNotFoundError,
@@ -17,7 +18,7 @@ logger = logging.getLogger(__name__)
17
18
 
18
19
 
19
20
  class GerritChangeRevisionFile:
20
- def __init__(self, path: str, json: dict, change: str, revision: str, gerrit):
21
+ def __init__(self, path: str, json: dict, change: str, revision: str, gerrit: GerritClient):
21
22
  self.path = path
22
23
  self.json = json
23
24
  self.change = change
@@ -81,7 +82,7 @@ class GerritChangeRevisionFile:
81
82
  """
82
83
  endpoint = self.endpoint + "/diff"
83
84
  if intraline:
84
- endpoint += endpoint + "?intraline"
85
+ endpoint += "?intraline"
85
86
 
86
87
  return self.gerrit.get(endpoint)
87
88
 
@@ -111,7 +112,7 @@ class GerritChangeRevisionFile:
111
112
 
112
113
 
113
114
  class GerritChangeRevisionFiles:
114
- def __init__(self, change, revision, gerrit):
115
+ def __init__(self, change, revision, gerrit: GerritClient):
115
116
  self.change = change
116
117
  self.revision = revision
117
118
  self.gerrit = gerrit
@@ -1,16 +1,17 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
4
5
  from gerrit.utils.gerritbase import GerritBase
5
6
 
6
7
 
7
8
  class GerritChangeMessage(GerritBase):
8
- def __init__(self, id: str, change: str, gerrit):
9
+ def __init__(self, id: str, change: str, gerrit: GerritClient):
9
10
  self.id = id
10
11
  self.change = change
11
12
  self.gerrit = gerrit
12
13
  self.endpoint = f"/changes/{self.change}/messages/{self.id}"
13
- super().__init__(self)
14
+ super().__init__()
14
15
 
15
16
  def __str__(self):
16
17
  return self.id
@@ -47,7 +48,7 @@ class GerritChangeMessage(GerritBase):
47
48
 
48
49
 
49
50
  class GerritChangeMessages:
50
- def __init__(self, change, gerrit):
51
+ def __init__(self, change, gerrit: GerritClient):
51
52
  self.change = change
52
53
  self.gerrit = gerrit
53
54
  self.endpoint = f"/changes/{self.change}/messages"
@@ -3,6 +3,7 @@
3
3
  # @Author: Jialiang Shi
4
4
  import logging
5
5
  import requests
6
+ from gerrit import GerritClient
6
7
  from gerrit.utils.gerritbase import GerritBase
7
8
  from gerrit.utils.exceptions import (
8
9
  ReviewerNotFoundError,
@@ -14,12 +15,12 @@ logger = logging.getLogger(__name__)
14
15
 
15
16
 
16
17
  class GerritChangeReviewer(GerritBase):
17
- def __init__(self, account: str, change: str, gerrit):
18
+ def __init__(self, account: str, change: str, gerrit: GerritClient):
18
19
  self.account = account
19
20
  self.change = change
20
21
  self.gerrit = gerrit
21
22
  self.endpoint = f"/changes/{self.change}/reviewers/{self.account}"
22
- super().__init__(self)
23
+ super().__init__()
23
24
 
24
25
  def __str__(self):
25
26
  return str(self.account)
@@ -95,7 +96,7 @@ class GerritChangeReviewer(GerritBase):
95
96
 
96
97
 
97
98
  class GerritChangeReviewers:
98
- def __init__(self, change, gerrit):
99
+ def __init__(self, change, gerrit: GerritClient):
99
100
  self.change = change
100
101
  self.gerrit = gerrit
101
102
  self.endpoint = f"/changes/{self.change}/reviewers"
@@ -3,13 +3,14 @@
3
3
  # @Author: Jialiang Shi
4
4
  from base64 import b64decode
5
5
  from urllib.parse import quote_plus
6
+ from gerrit import GerritClient
6
7
  from gerrit.changes.drafts import GerritChangeRevisionDrafts
7
8
  from gerrit.changes.comments import GerritChangeRevisionComments
8
9
  from gerrit.changes.files import GerritChangeRevisionFiles
9
10
 
10
11
 
11
12
  class GerritChangeRevision:
12
- def __init__(self, gerrit, change, revision="current"):
13
+ def __init__(self, gerrit: GerritClient, change: str, revision: str = "current"):
13
14
  self.change = change
14
15
  self.revision = revision
15
16
  self.gerrit = gerrit
@@ -207,14 +208,18 @@ class GerritChangeRevision:
207
208
  """
208
209
  endpoint = self.endpoint + "/patch"
209
210
 
211
+ query_params = []
210
212
  if zip_:
211
- endpoint += endpoint + "?zip"
213
+ query_params.append("zip")
212
214
 
213
215
  if download:
214
- endpoint += endpoint + "?download"
216
+ query_params.append("download")
215
217
 
216
218
  if path:
217
- endpoint += endpoint + f"?path={quote_plus(path)}"
219
+ query_params.append(f"path={quote_plus(path)}")
220
+
221
+ if query_params:
222
+ endpoint += "?" + "&".join(query_params)
218
223
 
219
224
  result = self.gerrit.get(endpoint)
220
225
  if decode:
@@ -258,7 +263,7 @@ class GerritChangeRevision:
258
263
  return self.gerrit.post(
259
264
  self.endpoint + "/test.submit_type",
260
265
  data=input_,
261
- headers={"Content-Type": "plain/text"},
266
+ headers={"Content-Type": "text/plain"},
262
267
  )
263
268
 
264
269
  def test_submit_rule(self, input_):
@@ -272,7 +277,7 @@ class GerritChangeRevision:
272
277
  return self.gerrit.post(
273
278
  self.endpoint + "/test.submit_rule",
274
279
  data=input_,
275
- headers={"Content-Type": "plain/text"},
280
+ headers={"Content-Type": "text/plain"},
276
281
  )
277
282
 
278
283
  @property
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
5
+
4
6
  class Cache:
5
- def __init__(self, name: str, gerrit):
7
+ def __init__(self, name: str, gerrit: GerritClient):
6
8
  self.name = name
7
9
  self.gerrit = gerrit
8
10
  self.endpoint = f"/config/server/caches/{self.name}"
@@ -17,7 +19,7 @@ class Cache:
17
19
 
18
20
 
19
21
  class Caches:
20
- def __init__(self, gerrit):
22
+ def __init__(self, gerrit: GerritClient):
21
23
  self.gerrit = gerrit
22
24
  self.endpoint = "/config/server/caches"
23
25
 
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
4
5
  from gerrit.config.caches import Caches
5
6
  from gerrit.config.tasks import Tasks
6
7
 
7
8
 
8
9
  class GerritConfig:
9
- def __init__(self, gerrit):
10
+ def __init__(self, gerrit: GerritClient):
10
11
  self.gerrit = gerrit
11
12
  self.endpoint = "/config/server"
12
13
 
@@ -1,8 +1,10 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
5
+
4
6
  class Task:
5
- def __init__(self, task_id: str, gerrit):
7
+ def __init__(self, task_id: str, gerrit: GerritClient):
6
8
  self.id = task_id
7
9
  self.gerrit = gerrit
8
10
  self.endpoint = f"/config/server/tasks/{self.id}"
@@ -18,7 +20,7 @@ class Task:
18
20
 
19
21
 
20
22
  class Tasks:
21
- def __init__(self, gerrit):
23
+ def __init__(self, gerrit: GerritClient):
22
24
  self.gerrit = gerrit
23
25
  self.endpoint = "/config/server/tasks"
24
26
 
@@ -1,17 +1,18 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
+ from gerrit import GerritClient
4
5
  from gerrit.utils.gerritbase import GerritBase
5
6
  from gerrit.groups.members import GerritGroupMembers
6
7
  from gerrit.groups.subgroups import GerritGroupSubGroups
7
8
 
8
9
 
9
10
  class GerritGroup(GerritBase):
10
- def __init__(self, group_id: int, gerrit):
11
+ def __init__(self, group_id: str, gerrit: GerritClient):
11
12
  self.id = group_id
12
13
  self.gerrit = gerrit
13
14
  self.endpoint = f"/groups/{self.id}"
14
- super().__init__(self)
15
+ super().__init__()
15
16
 
16
17
  def __str__(self):
17
18
  return self.id