python-epo-ops-client 4.2.0__py3-none-any.whl → 4.2.2__py3-none-any.whl

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.
epo_ops/api.py CHANGED
@@ -10,17 +10,12 @@ from requests.exceptions import HTTPError
10
10
 
11
11
  from . import exceptions
12
12
  from .middlewares import Throttler
13
- from .models import (
14
- NETWORK_TIMEOUT,
15
- AccessToken,
16
- Docdb,
17
- Epodoc,
18
- Original,
19
- Request,
20
- )
13
+ from .models import AccessToken, Docdb, Epodoc, Original, Request
21
14
 
22
15
  log = logging.getLogger(__name__)
23
16
 
17
+ DEFAULT_NETWORK_TIMEOUT = 10.0
18
+
24
19
 
25
20
  class Client(object):
26
21
  __auth_url__ = "https://ops.epo.org/3.2/auth/accesstoken"
@@ -35,14 +30,24 @@ class Client(object):
35
30
  __register_path__ = "register"
36
31
  __register_search_path__ = "register/search"
37
32
 
38
- def __init__(self, key, secret, accept_type="xml", middlewares=None):
33
+ def __init__(
34
+ self,
35
+ key,
36
+ secret,
37
+ accept_type="xml",
38
+ middlewares=None,
39
+ timeout=DEFAULT_NETWORK_TIMEOUT,
40
+ raise_for_status=True,
41
+ ):
39
42
  self.accept_type = "application/{0}".format(accept_type)
40
43
  self.middlewares = middlewares
41
44
  if middlewares is None:
42
45
  self.middlewares = [Throttler()]
43
- self.request = Request(self.middlewares)
46
+ self.request = Request(self.middlewares, timeout)
44
47
  self.key = key
45
48
  self.secret = secret
49
+ self.timeout = timeout
50
+ self.raise_for_status = raise_for_status
46
51
  self._access_token = None
47
52
 
48
53
  def family(
@@ -153,6 +158,7 @@ class Client(object):
153
158
  input=input,
154
159
  )
155
160
  )
161
+
156
162
  def number(
157
163
  self,
158
164
  reference_type: str,
@@ -351,7 +357,7 @@ class Client(object):
351
357
  self.__auth_url__,
352
358
  headers=headers,
353
359
  data=payload,
354
- timeout=NETWORK_TIMEOUT,
360
+ timeout=self.timeout,
355
361
  )
356
362
  response.raise_for_status()
357
363
  self._access_token = AccessToken(response)
@@ -394,7 +400,8 @@ class Client(object):
394
400
  )
395
401
  response = self._check_for_expired_token(response)
396
402
  response = self._check_for_exceeded_quota(response)
397
- response.raise_for_status()
403
+ if self.raise_for_status:
404
+ response.raise_for_status()
398
405
  return response
399
406
 
400
407
  # info: {
epo_ops/models.py CHANGED
@@ -11,9 +11,6 @@ from .utils import quote, validate_date
11
11
  log = logging.getLogger(__name__)
12
12
 
13
13
 
14
- NETWORK_TIMEOUT = 10.0
15
-
16
-
17
14
  def _prepare_part(part):
18
15
  return "({0})".format(quote(part))
19
16
 
@@ -68,8 +65,9 @@ class AccessToken(object):
68
65
 
69
66
 
70
67
  class Request(object):
71
- def __init__(self, middlewares):
68
+ def __init__(self, middlewares, timeout=None):
72
69
  self.middlewares = middlewares
70
+ self.timeout = timeout
73
71
  self.reset_env()
74
72
 
75
73
  @property
@@ -86,10 +84,10 @@ class Request(object):
86
84
  self.env.update(self.default_env)
87
85
 
88
86
  def post(self, url, data=None, **kwargs):
89
- return self._request(_post_callback, url, data, **kwargs)
87
+ return self._request(self._post_callback, url, data, **kwargs)
90
88
 
91
89
  def get(self, url, data=None, **kwargs):
92
- return self._request(_get_callback, url, data, **kwargs)
90
+ return self._request(self._get_callback, url, data, **kwargs)
93
91
 
94
92
  def _request(self, callback, url, data=None, **kwargs):
95
93
  self.reset_env()
@@ -110,10 +108,8 @@ class Request(object):
110
108
  self.reset_env()
111
109
  return response
112
110
 
111
+ def _post_callback(self, url, data, **kwargs):
112
+ return requests.post(url, data, **kwargs, timeout=self.timeout)
113
113
 
114
- def _post_callback(url, data, **kwargs):
115
- return requests.post(url, data, **kwargs, timeout=NETWORK_TIMEOUT)
116
-
117
-
118
- def _get_callback(url, data, **kwargs):
119
- return requests.get(url, **kwargs, timeout=NETWORK_TIMEOUT)
114
+ def _get_callback(self, url, data, **kwargs):
115
+ return requests.get(url, **kwargs, timeout=self.timeout)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-epo-ops-client
3
- Version: 4.2.0
3
+ Version: 4.2.2
4
4
  Summary: Python client for EPO OPS, the European Patent Office's Open Patent Services API.
5
5
  Home-page: https://github.com/ip-tools/python-epo-ops-client
6
6
  Download-URL: https://pypi.org/project/python-epo-ops-client/#files
@@ -8,11 +8,11 @@ Author: George Song
8
8
  Author-email: george@monozuku.com
9
9
  Maintainer: Andreas Motl
10
10
  Maintainer-email: andreas.motl@ip-tools.org
11
+ License: Apache-2.0
11
12
  Keywords: ops,epo,epo-ops,patent-data,patent-office,patent-data-api,european patent office,open patent services
12
13
  Classifier: Development Status :: 5 - Production/Stable
13
14
  Classifier: Intended Audience :: Developers
14
15
  Classifier: Natural Language :: English
15
- Classifier: License :: OSI Approved :: Apache Software License
16
16
  Classifier: Programming Language :: Python
17
17
  Classifier: Programming Language :: Python :: 3.6
18
18
  Classifier: Programming Language :: Python :: 3.7
@@ -22,25 +22,27 @@ Classifier: Programming Language :: Python :: 3.10
22
22
  Classifier: Programming Language :: Python :: 3.11
23
23
  Classifier: Programming Language :: Python :: 3.12
24
24
  Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
25
26
  Classifier: Topic :: Software Development :: Libraries
26
27
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
28
  Description-Content-Type: text/markdown
28
29
  License-File: LICENSE
29
- Requires-Dist: dogpile.cache<1.5
30
+ Requires-Dist: dogpile.cache<1.6
30
31
  Requires-Dist: importlib-metadata; python_version < "3.8"
31
32
  Requires-Dist: python-dateutil<2.10
32
33
  Requires-Dist: requests<3,>=2.27
33
34
  Requires-Dist: six<2
34
35
  Provides-Extra: develop
35
- Requires-Dist: ruff<0.13; python_version >= "3.7" and extra == "develop"
36
+ Requires-Dist: pyproject-fmt<3; extra == "develop"
37
+ Requires-Dist: ruff<0.16; python_version >= "3.7" and extra == "develop"
36
38
  Requires-Dist: twine<7; extra == "develop"
37
39
  Requires-Dist: wheel<1; extra == "develop"
38
40
  Provides-Extra: test
39
- Requires-Dist: pytest<9; extra == "test"
41
+ Requires-Dist: pytest<10; extra == "test"
40
42
  Requires-Dist: pytest-cache<2; extra == "test"
41
- Requires-Dist: pytest-cov<6.3; extra == "test"
42
- Requires-Dist: python-dotenv<1.2; extra == "test"
43
- Requires-Dist: responses<0.26; extra == "test"
43
+ Requires-Dist: pytest-cov<7.2; extra == "test"
44
+ Requires-Dist: python-dotenv<1.3; extra == "test"
45
+ Requires-Dist: responses<0.27; extra == "test"
44
46
  Dynamic: author
45
47
  Dynamic: author-email
46
48
  Dynamic: classifier
@@ -49,6 +51,7 @@ Dynamic: description-content-type
49
51
  Dynamic: download-url
50
52
  Dynamic: home-page
51
53
  Dynamic: keywords
54
+ Dynamic: license
52
55
  Dynamic: license-file
53
56
  Dynamic: maintainer
54
57
  Dynamic: maintainer-email
@@ -125,9 +128,11 @@ you'll interact with mostly.
125
128
 
126
129
  When you issue a request, the response is a [requests.Response][] object. If
127
130
  `response.status_code != 200` then a `requests.HTTPError` exception will be
128
- raised — it's your responsibility to handle those exceptions if you want to. The
129
- one case that's handled is when the access token has expired: in this case, the
130
- client will automatically handle the HTTP 400 status and renew the token.
131
+ raised — it's your responsibility to handle those exceptions if you want to.
132
+ This default can be disabled by passing `raise_for_status=False` when
133
+ constructing the client. The one case that's handled is when the access token
134
+ has expired: in this case, the client will automatically handle the HTTP 400
135
+ status and renew the token.
131
136
 
132
137
  Note that the Client does not attempt to interpret the data supplied by OPS, so
133
138
  it's your responsibility to parse the XML or JSON payload for your own purpose.
@@ -1,8 +1,8 @@
1
1
  epo_ops/__init__.py,sha256=FBeuePcy1kzPa9r8eVbJKuCTH7KraksI9RxpBcOqWXc,571
2
2
  epo_ops/__version__.py,sha256=oPE9VFlJQnVOEwuJbON4aK7XhyF3CB86MEnkbhJ0NTU,204
3
- epo_ops/api.py,sha256=3Oft8shAW-kh1r4DezcvoPBA-da1BvmI35n_uLJl6oQ,16621
3
+ epo_ops/api.py,sha256=4GYTZYuD4JkM9LnneEG6vqznuWQAvtPRNb6vga0Nce4,16851
4
4
  epo_ops/exceptions.py,sha256=MYaRMNHBH1REggRn0Lmp8_acnHbFb9uq51HFS-qz6c4,620
5
- epo_ops/models.py,sha256=RU2c4b6TzhyMj5ML4_XLN-N3YNZlna_kQ-hE1oNBIW0,3391
5
+ epo_ops/models.py,sha256=dzin5dHJJng0Zv1fFVoFXVDY20ZdAuayQQwFsEgrNPs,3441
6
6
  epo_ops/utils.py,sha256=mGy57QUSgpQG21_nbHEj6ZMqoxeAK8TbFwohfGDB6xw,776
7
7
  epo_ops/middlewares/__init__.py,sha256=y6MT9llD5jdVduGHUghGr1tgssvoJ75-0L4WlFPe3pw,178
8
8
  epo_ops/middlewares/middleware.py,sha256=kXo58_kju4IlM7vTAVwmn2Ynk5O-ZIdoWw2slonT_nY,518
@@ -16,8 +16,8 @@ epo_ops/middlewares/throttle/utils.py,sha256=DezWXXGJw9GoNk4lPtHVKQ0FZXJo98jgCzv
16
16
  epo_ops/middlewares/throttle/storages/__init__.py,sha256=VtpaDmfxeQM2-tc9tad5-_DTFYp4n-Ec4QPPi6niglw,81
17
17
  epo_ops/middlewares/throttle/storages/sqlite.py,sha256=frYBYpDyay4pTfGrVatqZVsIBATlvGqo-4zZJFddSO4,4934
18
18
  epo_ops/middlewares/throttle/storages/storage.py,sha256=FLJ0kvUSDaI_fiHuXbT3UVNRmXcAPS5M2v3vYEYBgQY,757
19
- python_epo_ops_client-4.2.0.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
20
- python_epo_ops_client-4.2.0.dist-info/METADATA,sha256=rkkdiqIyKKasErPSPeH6oStlsRVhyDPR9H_0DDWpgr8,10419
21
- python_epo_ops_client-4.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
22
- python_epo_ops_client-4.2.0.dist-info/top_level.txt,sha256=0e54UaEWTAp3B6Xh_hZvJnuTK3iB0xtm57WxsW8xJkI,8
23
- python_epo_ops_client-4.2.0.dist-info/RECORD,,
19
+ python_epo_ops_client-4.2.2.dist-info/licenses/LICENSE,sha256=psuoW8kuDP96RQsdhzwOqi6fyWv0ct8CR6Jr7He_P_k,10173
20
+ python_epo_ops_client-4.2.2.dist-info/METADATA,sha256=4v6zbfJDHea4i9KgjR33pkA86g4uP759WyLwQQheONU,10591
21
+ python_epo_ops_client-4.2.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
22
+ python_epo_ops_client-4.2.2.dist-info/top_level.txt,sha256=0e54UaEWTAp3B6Xh_hZvJnuTK3iB0xtm57WxsW8xJkI,8
23
+ python_epo_ops_client-4.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (82.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5