python-gerrit-api 3.0.7__tar.gz → 3.0.9__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 (63) hide show
  1. {python-gerrit-api-3.0.7/python_gerrit_api.egg-info → python_gerrit_api-3.0.9}/PKG-INFO +3 -1
  2. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/README.rst +2 -0
  3. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/__init__.py +1 -1
  4. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/base.py +33 -6
  5. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/changes.py +1 -1
  6. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/utils/requester.py +1 -18
  7. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gitiles/base.py +21 -5
  8. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9/python_gerrit_api.egg-info}/PKG-INFO +3 -1
  9. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/LICENSE +0 -0
  10. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/MANIFEST.in +0 -0
  11. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/accounts/__init__.py +0 -0
  12. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/accounts/account.py +0 -0
  13. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/accounts/accounts.py +0 -0
  14. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/accounts/emails.py +0 -0
  15. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/accounts/gpg_keys.py +0 -0
  16. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/accounts/ssh_keys.py +0 -0
  17. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/__init__.py +0 -0
  18. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/change.py +0 -0
  19. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/comments.py +0 -0
  20. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/drafts.py +0 -0
  21. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/edit.py +0 -0
  22. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/files.py +0 -0
  23. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/messages.py +0 -0
  24. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/reviewers.py +0 -0
  25. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/changes/revision.py +0 -0
  26. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/config/__init__.py +0 -0
  27. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/config/caches.py +0 -0
  28. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/config/config.py +0 -0
  29. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/config/tasks.py +0 -0
  30. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/groups/__init__.py +0 -0
  31. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/groups/group.py +0 -0
  32. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/groups/groups.py +0 -0
  33. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/groups/members.py +0 -0
  34. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/groups/subgroups.py +0 -0
  35. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/plugins/__init__.py +0 -0
  36. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/plugins/plugins.py +0 -0
  37. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/__init__.py +0 -0
  38. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/branches.py +0 -0
  39. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/commit.py +0 -0
  40. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/dashboards.py +0 -0
  41. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/labels.py +0 -0
  42. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/project.py +0 -0
  43. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/projects.py +0 -0
  44. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/tags.py +0 -0
  45. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/projects/webhooks.py +0 -0
  46. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/utils/__init__.py +0 -0
  47. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/utils/common.py +0 -0
  48. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/utils/exceptions.py +0 -0
  49. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gerrit/utils/gerritbase.py +0 -0
  50. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/gitiles/__init__.py +0 -0
  51. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/python_gerrit_api.egg-info/SOURCES.txt +0 -0
  52. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/python_gerrit_api.egg-info/dependency_links.txt +0 -0
  53. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/python_gerrit_api.egg-info/requires.txt +0 -0
  54. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/python_gerrit_api.egg-info/top_level.txt +0 -0
  55. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/requirements.txt +0 -0
  56. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/setup.cfg +0 -0
  57. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/setup.py +0 -0
  58. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/tests/test_accounts.py +0 -0
  59. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/tests/test_changes.py +0 -0
  60. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/tests/test_gitiles.py +0 -0
  61. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/tests/test_groups.py +0 -0
  62. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/tests/test_projects.py +0 -0
  63. {python-gerrit-api-3.0.7 → python_gerrit_api-3.0.9}/tests/test_revision.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-gerrit-api
3
- Version: 3.0.7
3
+ Version: 3.0.9
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
@@ -26,6 +26,8 @@ Requires-Dist: requests
26
26
  Project description
27
27
  ===================
28
28
 
29
+ .. image:: https://repobeats.axiom.co/api/embed/89080ed0f569186ab5d752a9585870f515e2f131.svg
30
+
29
31
  .. image:: https://img.shields.io/pypi/pyversions/python-gerrit-api.svg
30
32
  :target: https://pypi.python.org/pypi/python-gerrit-api
31
33
  .. 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,6 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
- __version__ = "3.0.7"
4
+ __version__ = "3.0.9"
5
5
 
6
6
  from gerrit.base import GerritClient
@@ -2,6 +2,8 @@
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
4
  import netrc
5
+ import requests
6
+ from requests.adapters import HTTPAdapter
5
7
  from gerrit.utils.requester import Requester
6
8
  from gerrit.utils.common import decode_response, strip_trailing_slash
7
9
  from gerrit.config.config import GerritConfig
@@ -28,25 +30,50 @@ class GerritClient:
28
30
  use_netrc=False,
29
31
  ssl_verify=True,
30
32
  cert=None,
33
+ cookies=None,
34
+ cookie_jar=None,
31
35
  timeout=60,
32
36
  max_retries=None,
37
+ session=None,
33
38
  auth_suffix="/a",
34
39
  ):
35
40
  self._base_url = strip_trailing_slash(base_url)
36
41
 
42
+ # make request session if one isn't provided
43
+ if session is None:
44
+ session = requests.Session()
45
+
37
46
  if use_netrc:
38
47
  password = self.get_password_from_netrc_file()
39
48
 
49
+ if username and password:
50
+ session.auth = (username, password)
51
+
52
+ if ssl_verify:
53
+ session.verify = ssl_verify
54
+
55
+ if cert is not None:
56
+ session.cert = cert
57
+
58
+ if cookies is not None:
59
+ session.cookies.update(cookies)
60
+
61
+ if cookie_jar is not None:
62
+ session.cookies = cookie_jar
63
+
64
+ if max_retries is not None:
65
+ retry_adapter = HTTPAdapter(max_retries=max_retries)
66
+ session.mount("http://", retry_adapter)
67
+ session.mount("https://", retry_adapter)
68
+
69
+ self.session = session
70
+
40
71
  self.requester = Requester(
41
72
  base_url=base_url,
42
- username=username,
43
- password=password,
44
- ssl_verify=ssl_verify,
45
- cert=cert,
73
+ session=self.session,
46
74
  timeout=timeout,
47
- max_retries=max_retries,
48
75
  )
49
- if username and password:
76
+ if self.session.auth is not None:
50
77
  self.auth_suffix = auth_suffix
51
78
  else:
52
79
  self.auth_suffix = ""
@@ -57,7 +57,7 @@ class GerritChanges:
57
57
  except requests.exceptions.HTTPError as error:
58
58
  if error.response.status_code == 404:
59
59
  message = f"Change {id_} does not exist"
60
- if id_.startswith("I"):
60
+ if isinstance(id_, str) and id_.startswith("I"):
61
61
  res = self.search(query=f"change: {id_}")
62
62
  if len(res) > 0:
63
63
  change_ids = [item.get("id") for item in res]
@@ -2,8 +2,6 @@
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
4
  import urllib.parse as urlparse
5
- from requests import Session
6
- from requests.adapters import HTTPAdapter
7
5
  from gerrit.utils.exceptions import (
8
6
  NotAllowedError,
9
7
  ValidationError,
@@ -36,18 +34,8 @@ class Requester:
36
34
  timeout = 10
37
35
  base_url = kwargs.get("base_url")
38
36
  self.base_scheme = urlparse.urlsplit(base_url).scheme if base_url else None
39
- self.username = kwargs.get("username")
40
- self.password = kwargs.get("password")
41
- self.ssl_verify = kwargs.get("ssl_verify")
42
- self.cert = kwargs.get("cert")
37
+ self.session = kwargs.get("session")
43
38
  self.timeout = kwargs.get("timeout", timeout)
44
- self.session = Session()
45
-
46
- self.max_retries = kwargs.get("max_retries")
47
- if self.max_retries is not None:
48
- retry_adapter = HTTPAdapter(max_retries=self.max_retries)
49
- self.session.mount("http://", retry_adapter)
50
- self.session.mount("https://", retry_adapter)
51
39
 
52
40
  def _update_url_scheme(self, url):
53
41
  """
@@ -78,8 +66,6 @@ class Requester:
78
66
  :return:
79
67
  """
80
68
  request_kwargs = kwargs
81
- if self.username and self.password:
82
- request_kwargs["auth"] = (self.username, self.password)
83
69
 
84
70
  if params:
85
71
  if not isinstance(params, dict):
@@ -98,9 +84,6 @@ class Requester:
98
84
  currentheaders.update({"Cookie": self.AUTH_COOKIE})
99
85
  request_kwargs["headers"] = currentheaders
100
86
 
101
- request_kwargs["verify"] = self.ssl_verify
102
- request_kwargs["cert"] = self.cert
103
-
104
87
  if data and json:
105
88
  raise ValueError("Cannot use data and json together")
106
89
 
@@ -3,6 +3,8 @@
3
3
  # @Author: Jialiang Shi
4
4
  from typing import Optional
5
5
  from base64 import b64decode
6
+ import requests
7
+ from requests.adapters import HTTPAdapter
6
8
  from gerrit.utils.requester import Requester
7
9
  from gerrit.utils.common import decode_response, strip_trailing_slash
8
10
 
@@ -20,14 +22,28 @@ class GitilesClient:
20
22
  ):
21
23
  self._base_url = strip_trailing_slash(base_url)
22
24
 
25
+ # make request session
26
+ _session = requests.Session()
27
+ if username and password:
28
+ _session.auth = (username, password)
29
+
30
+ if ssl_verify:
31
+ _session.verify = ssl_verify
32
+
33
+ if cert is not None:
34
+ _session.cert = cert
35
+
36
+ if max_retries is not None:
37
+ retry_adapter = HTTPAdapter(max_retries=max_retries)
38
+ _session.mount("http://", retry_adapter)
39
+ _session.mount("https://", retry_adapter)
40
+
41
+ self.session = _session
42
+
23
43
  self.requester = Requester(
24
44
  base_url=base_url,
25
- username=username,
26
- password=password,
27
- ssl_verify=ssl_verify,
28
- cert=cert,
45
+ session=self.session,
29
46
  timeout=timeout,
30
- max_retries=max_retries,
31
47
  )
32
48
 
33
49
  def get_endpoint_url(self, endpoint):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-gerrit-api
3
- Version: 3.0.7
3
+ Version: 3.0.9
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
@@ -26,6 +26,8 @@ Requires-Dist: requests
26
26
  Project description
27
27
  ===================
28
28
 
29
+ .. image:: https://repobeats.axiom.co/api/embed/89080ed0f569186ab5d752a9585870f515e2f131.svg
30
+
29
31
  .. image:: https://img.shields.io/pypi/pyversions/python-gerrit-api.svg
30
32
  :target: https://pypi.python.org/pypi/python-gerrit-api
31
33
  .. image:: https://img.shields.io/pypi/v/python-gerrit-api.svg