python-gerrit-api 3.0.8__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.8/python_gerrit_api.egg-info → python_gerrit_api-3.1.0}/PKG-INFO +16 -2
  2. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/README.rst +2 -0
  3. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/__init__.py +3 -1
  4. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/accounts/account.py +3 -2
  5. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/accounts/accounts.py +6 -3
  6. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/accounts/emails.py +4 -3
  7. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/accounts/gpg_keys.py +4 -3
  8. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/accounts/ssh_keys.py +4 -3
  9. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/base.py +41 -19
  10. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/change.py +3 -2
  11. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/changes.py +2 -1
  12. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/comments.py +4 -3
  13. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/drafts.py +4 -3
  14. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/edit.py +4 -3
  15. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/files.py +4 -3
  16. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/messages.py +4 -3
  17. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/reviewers.py +4 -3
  18. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/revision.py +11 -6
  19. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/config/caches.py +4 -2
  20. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/config/config.py +2 -1
  21. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/config/tasks.py +4 -2
  22. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/groups/group.py +3 -2
  23. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/groups/groups.py +4 -3
  24. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/groups/members.py +2 -2
  25. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/groups/subgroups.py +2 -1
  26. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/plugins/plugins.py +3 -2
  27. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/branches.py +4 -3
  28. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/commit.py +3 -2
  29. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/dashboards.py +4 -3
  30. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/labels.py +4 -3
  31. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/project.py +3 -2
  32. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/projects.py +4 -2
  33. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/tags.py +4 -3
  34. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/webhooks.py +4 -3
  35. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/utils/common.py +3 -1
  36. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/utils/gerritbase.py +6 -3
  37. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gitiles/__init__.py +2 -0
  38. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0/python_gerrit_api.egg-info}/PKG-INFO +16 -2
  39. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/SOURCES.txt +1 -0
  40. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/setup.py +1 -0
  41. python_gerrit_api-3.1.0/tests/test_accounts.py +364 -0
  42. python_gerrit_api-3.1.0/tests/test_changes.py +480 -0
  43. python_gerrit_api-3.1.0/tests/test_config_and_plugins.py +290 -0
  44. python_gerrit_api-3.1.0/tests/test_gitiles.py +122 -0
  45. python_gerrit_api-3.1.0/tests/test_groups.py +261 -0
  46. python_gerrit_api-3.1.0/tests/test_projects.py +475 -0
  47. python_gerrit_api-3.1.0/tests/test_revision.py +381 -0
  48. python_gerrit_api-3.0.8/tests/test_accounts.py +0 -283
  49. python_gerrit_api-3.0.8/tests/test_changes.py +0 -177
  50. python_gerrit_api-3.0.8/tests/test_gitiles.py +0 -40
  51. python_gerrit_api-3.0.8/tests/test_groups.py +0 -126
  52. python_gerrit_api-3.0.8/tests/test_projects.py +0 -340
  53. python_gerrit_api-3.0.8/tests/test_revision.py +0 -167
  54. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/LICENSE +0 -0
  55. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/MANIFEST.in +0 -0
  56. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/accounts/__init__.py +0 -0
  57. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/changes/__init__.py +0 -0
  58. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/config/__init__.py +0 -0
  59. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/groups/__init__.py +0 -0
  60. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/plugins/__init__.py +0 -0
  61. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/projects/__init__.py +0 -0
  62. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/utils/__init__.py +0 -0
  63. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/utils/exceptions.py +0 -0
  64. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gerrit/utils/requester.py +0 -0
  65. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/gitiles/base.py +0 -0
  66. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/dependency_links.txt +0 -0
  67. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/requires.txt +0 -0
  68. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/python_gerrit_api.egg-info/top_level.txt +0 -0
  69. {python_gerrit_api-3.0.8 → python_gerrit_api-3.1.0}/requirements.txt +0 -0
  70. {python_gerrit_api-3.0.8 → 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.8
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,12 +20,26 @@ 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
  ===================
28
40
 
41
+ .. image:: https://repobeats.axiom.co/api/embed/89080ed0f569186ab5d752a9585870f515e2f131.svg
42
+
29
43
  .. image:: https://img.shields.io/pypi/pyversions/python-gerrit-api.svg
30
44
  :target: https://pypi.python.org/pypi/python-gerrit-api
31
45
  .. image:: https://img.shields.io/pypi/v/python-gerrit-api.svg
@@ -1,6 +1,8 @@
1
1
  Project description
2
2
  ===================
3
3
 
4
+ .. image:: https://repobeats.axiom.co/api/embed/89080ed0f569186ab5d752a9585870f515e2f131.svg
5
+
4
6
  .. image:: https://img.shields.io/pypi/pyversions/python-gerrit-api.svg
5
7
  :target: https://pypi.python.org/pypi/python-gerrit-api
6
8
  .. image:: https://img.shields.io/pypi/v/python-gerrit-api.svg
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
- __version__ = "3.0.8"
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:
@@ -30,39 +27,50 @@ class GerritClient:
30
27
  use_netrc=False,
31
28
  ssl_verify=True,
32
29
  cert=None,
30
+ cookies=None,
31
+ cookie_jar=None,
33
32
  timeout=60,
34
33
  max_retries=None,
34
+ session=None,
35
35
  auth_suffix="/a",
36
36
  ):
37
37
  self._base_url = strip_trailing_slash(base_url)
38
38
 
39
+ # make request session if one isn't provided
40
+ if session is None:
41
+ session = requests.Session()
42
+
39
43
  if use_netrc:
40
44
  password = self.get_password_from_netrc_file()
41
45
 
42
- # make request session
43
- _session = requests.Session()
44
46
  if username and password:
45
- _session.auth = (username, password)
47
+ session.auth = (username, password)
46
48
 
47
49
  if ssl_verify:
48
- _session.verify = ssl_verify
50
+ session.verify = ssl_verify
49
51
 
50
52
  if cert is not None:
51
- _session.cert = cert
53
+ session.cert = cert
54
+
55
+ if cookies is not None:
56
+ session.cookies.update(cookies)
57
+
58
+ if cookie_jar is not None:
59
+ session.cookies = cookie_jar
52
60
 
53
61
  if max_retries is not None:
54
62
  retry_adapter = HTTPAdapter(max_retries=max_retries)
55
- _session.mount("http://", retry_adapter)
56
- _session.mount("https://", retry_adapter)
63
+ session.mount("http://", retry_adapter)
64
+ session.mount("https://", retry_adapter)
57
65
 
58
- self.session = _session
66
+ self.session = session
59
67
 
60
68
  self.requester = Requester(
61
69
  base_url=base_url,
62
70
  session=self.session,
63
71
  timeout=timeout,
64
72
  )
65
- if username and password:
73
+ if self.session.auth is not None:
66
74
  self.auth_suffix = auth_suffix
67
75
  else:
68
76
  self.auth_suffix = ""
@@ -96,6 +104,7 @@ class GerritClient:
96
104
 
97
105
  :return:
98
106
  """
107
+ from gerrit.config.config import GerritConfig
99
108
  return GerritConfig(gerrit=self)
100
109
 
101
110
  @property
@@ -104,6 +113,7 @@ class GerritClient:
104
113
  Project related REST APIs
105
114
  :return:
106
115
  """
116
+ from gerrit.projects.projects import GerritProjects
107
117
  return GerritProjects(gerrit=self)
108
118
 
109
119
  @property
@@ -113,6 +123,7 @@ class GerritClient:
113
123
 
114
124
  :return:
115
125
  """
126
+ from gerrit.changes.changes import GerritChanges
116
127
  return GerritChanges(gerrit=self)
117
128
 
118
129
  @property
@@ -122,6 +133,7 @@ class GerritClient:
122
133
 
123
134
  :return:
124
135
  """
136
+ from gerrit.accounts.accounts import GerritAccounts
125
137
  return GerritAccounts(gerrit=self)
126
138
 
127
139
  @property
@@ -131,6 +143,7 @@ class GerritClient:
131
143
 
132
144
  :return:
133
145
  """
146
+ from gerrit.groups.groups import GerritGroups
134
147
  return GerritGroups(gerrit=self)
135
148
 
136
149
  @property
@@ -140,6 +153,7 @@ class GerritClient:
140
153
 
141
154
  :return:
142
155
  """
156
+ from gerrit.plugins.plugins import GerritPlugins
143
157
  return GerritPlugins(gerrit=self)
144
158
 
145
159
  @property
@@ -167,7 +181,9 @@ class GerritClient:
167
181
  :param endpoint: The endpoint to send to.
168
182
  :return:
169
183
  """
170
- 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)
171
187
  result = decode_response(response)
172
188
  return result
173
189
 
@@ -178,7 +194,9 @@ class GerritClient:
178
194
  :param endpoint: The endpoint to send to.
179
195
  :return:
180
196
  """
181
- 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)
182
200
  result = decode_response(response)
183
201
  return result
184
202
 
@@ -189,7 +207,9 @@ class GerritClient:
189
207
  :param endpoint: The endpoint to send to.
190
208
  :return:
191
209
  """
192
- 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)
193
213
  result = decode_response(response)
194
214
  return result
195
215
 
@@ -200,4 +220,6 @@ class GerritClient:
200
220
  :param endpoint: The endpoint to send to.
201
221
  :return:
202
222
  """
203
- 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