drb-driver-http 1.2.0__tar.gz → 1.3.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 (31) hide show
  1. {drb-driver-http-1.2.0/drb_driver_http.egg-info → drb-driver-http-1.3.0}/PKG-INFO +3 -1
  2. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/drivers/http/_version.py +4 -4
  3. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/drivers/http/http.py +21 -55
  4. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0/drb_driver_http.egg-info}/PKG-INFO +3 -1
  5. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb_driver_http.egg-info/requires.txt +1 -1
  6. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/requirements.txt +1 -1
  7. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_http_keyring.py +2 -3
  8. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/LICENCE.txt +0 -0
  9. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/README.md +0 -0
  10. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/drivers/http/__init__.py +0 -0
  11. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/drivers/http/oauth2/HTTPOAuth2.py +0 -0
  12. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/drivers/http/oauth2/__init__.py +0 -0
  13. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/drivers/http/oauth2/oauth2.py +0 -0
  14. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/exceptions/http.py +0 -0
  15. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/topics/http/__init__.py +0 -0
  16. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb/topics/http/cortex.yml +0 -0
  17. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb_driver_http.egg-info/SOURCES.txt +0 -0
  18. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb_driver_http.egg-info/dependency_links.txt +0 -0
  19. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb_driver_http.egg-info/entry_points.txt +0 -0
  20. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb_driver_http.egg-info/not-zip-safe +0 -0
  21. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/drb_driver_http.egg-info/top_level.txt +0 -0
  22. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/pyproject.toml +0 -0
  23. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/setup.cfg +0 -0
  24. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/setup.py +0 -0
  25. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_http_basic_auth.py +0 -0
  26. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_http_bearer.py +0 -0
  27. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_http_factory.py +0 -0
  28. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_http_signature.py +0 -0
  29. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_https_signature.py +0 -0
  30. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/tests/test_drb_impl_http.py +0 -0
  31. {drb-driver-http-1.2.0 → drb-driver-http-1.3.0}/versioneer.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: drb-driver-http
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: DRB Http driver
5
5
  Author: GAEL Systems
6
6
  Author-email: drb-python@gael.fr
@@ -13,6 +13,8 @@ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGP
13
13
  Requires-Python: >=3.8
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENCE.txt
16
+ Requires-Dist: drb~=2.2.0
17
+ Requires-Dist: tenacity==8.0.1
16
18
 
17
19
  # Http & Https Implementation
18
20
  This drb-driver-http module implements http and https protocol access with DRB data model.
@@ -1,5 +1,5 @@
1
1
 
2
- # This file was generated by 'versioneer.py' (0.28) from
2
+ # This file was generated by 'versioneer.py' (0.29) from
3
3
  # revision-control system data, or from the parent directory name of an
4
4
  # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
5
  # of this file.
@@ -8,11 +8,11 @@ import json
8
8
 
9
9
  version_json = '''
10
10
  {
11
- "date": "2023-03-31T11:29:21+0200",
11
+ "date": "2023-09-12T17:43:20+0200",
12
12
  "dirty": false,
13
13
  "error": null,
14
- "full-revisionid": "f279acfe6c19a5daa445c7c9209f0ae5d4cc4b70",
15
- "version": "1.2.0"
14
+ "full-revisionid": "38308644bfd44c075f46f5b42c6f3c2daca93a1e",
15
+ "version": "1.3.0"
16
16
  }
17
17
  ''' # END VERSION_JSON
18
18
 
@@ -251,7 +251,7 @@ class DrbHttpNode(AbstractNode):
251
251
  self._auth = auth
252
252
  self._params = params
253
253
  self._children = []
254
- self._available_impl.append(io.BytesIO)
254
+ self.add_impl(io.BytesIO, _to_stream)
255
255
 
256
256
  def __init_header(self):
257
257
  if len(self._attrs) == 0:
@@ -279,18 +279,17 @@ class DrbHttpNode(AbstractNode):
279
279
 
280
280
  @property
281
281
  def auth(self) -> AuthBase:
282
- if self._auth is not None:
283
- if isinstance(self._auth, HTTPBasicAuth):
284
- credential = keyring.get_credential(
285
- self.path.path,
286
- self._auth.username
282
+ if self._auth is None:
283
+ credential = keyring.get_credential(
284
+ service_name=self.path.path,
285
+ username=None
286
+ )
287
+ if credential is not None:
288
+ self._auth = HTTPBasicAuth(
289
+ credential.username,
290
+ credential.password
287
291
  )
288
- if credential is not None:
289
- return HTTPBasicAuth(
290
- credential.username,
291
- credential.password
292
- )
293
- return self._auth
292
+ return self._auth
294
293
 
295
294
  def __setitem__(self, key, value):
296
295
  raise NotImplementedError
@@ -334,43 +333,6 @@ class DrbHttpNode(AbstractNode):
334
333
  raise DrbException(f'Attribute not found name: {name}, '
335
334
  f'namespace: {namespace_uri}')
336
335
 
337
- def get_impl(self, impl: type, **kwargs) -> Any:
338
- """
339
- This operation returns a reference to an object implementing a
340
- specific interface. This method authorizes a specific and/or direct
341
- API instead of using the DrbNode interface. The provided object is
342
- independent of this node and shall be released/closed by the caller
343
- when interface requires such finally operations.
344
-
345
- Parameters:
346
- impl (type): the implementation type expected
347
-
348
- Keyword Arguments:
349
- start (int): The first byte to be downloaded.
350
- end (int): The last byte to be downloaded.
351
-
352
- Return:
353
- Any: the expected implementation.
354
- Raises:
355
- DrbNotImplementedException: if `impl` is not supported by the
356
- current node
357
- """
358
- if self.has_impl(impl):
359
- headers = None
360
- if 'start' in kwargs:
361
- if 'end' in kwargs:
362
- headers = (kwargs.get('start'), kwargs.get('end'))
363
- else:
364
- headers = (kwargs.get('start'),)
365
- return Download(self.path.name,
366
- self.auth,
367
- self.params,
368
- headers,
369
- kwargs.get('chunk_size', 4 * 1048576)
370
- )
371
- raise DrbNotImplementationException(
372
- f'no {impl} implementation found')
373
-
374
336
  @staticmethod
375
337
  def post(url: str,
376
338
  headers: dict = None,
@@ -394,8 +356,16 @@ class DrbHttpNode(AbstractNode):
394
356
  auth=auth)
395
357
  return DrbHttpResponse(path=url, response=response)
396
358
 
397
- def close(self) -> None:
398
- pass
359
+
360
+ def _to_stream(node: DrbHttpNode, **kwargs):
361
+ headers = None
362
+ if 'start' in kwargs:
363
+ if 'end' in kwargs:
364
+ headers = (kwargs.get('start'), kwargs.get('end'))
365
+ else:
366
+ headers = (kwargs.get('start'),)
367
+ return Download(node.path.name, node.auth, node.params, headers,
368
+ kwargs.get('chunk_size', 4 * 1048576))
399
369
 
400
370
 
401
371
  class DrbHttpResponse(DrbHttpNode):
@@ -407,10 +377,6 @@ class DrbHttpResponse(DrbHttpNode):
407
377
  (k, None): v for k, v in self._resp.headers.items()
408
378
  }
409
379
  self.value = response.content
410
- self._available_impl.append(io.BytesIO)
411
-
412
- def get_impl(self, impl: type, **kwargs) -> Any:
413
- return io.BytesIO(self._resp.content)
414
380
 
415
381
 
416
382
  class DrbHttpFactory(DrbFactory):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: drb-driver-http
3
- Version: 1.2.0
3
+ Version: 1.3.0
4
4
  Summary: DRB Http driver
5
5
  Author: GAEL Systems
6
6
  Author-email: drb-python@gael.fr
@@ -13,6 +13,8 @@ Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGP
13
13
  Requires-Python: >=3.8
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENCE.txt
16
+ Requires-Dist: drb~=2.2.0
17
+ Requires-Dist: tenacity==8.0.1
16
18
 
17
19
  # Http & Https Implementation
18
20
  This drb-driver-http module implements http and https protocol access with DRB data model.
@@ -1,2 +1,2 @@
1
- drb~=2.1.3
1
+ drb~=2.2.0
2
2
  tenacity==8.0.1
@@ -1,2 +1,2 @@
1
- drb~=2.1.3
1
+ drb~=2.2.0
2
2
  tenacity==8.0.1
@@ -4,7 +4,6 @@ from unittest.mock import patch
4
4
  from multiprocessing import Process
5
5
 
6
6
  from keyring.credentials import SimpleCredential
7
- from requests.auth import HTTPBasicAuth
8
7
 
9
8
  from drb.drivers.http import DrbHttpNode
10
9
  from tests.utility import start_auth_serve, PORT, PATH
@@ -12,7 +11,7 @@ from tests.utility import start_auth_serve, PORT, PATH
12
11
  process = Process(target=start_auth_serve)
13
12
 
14
13
 
15
- def my_credential(usr, pwd):
14
+ def my_credential(service_name, username):
16
15
  return SimpleCredential('user', 'pwd123456')
17
16
 
18
17
 
@@ -29,7 +28,7 @@ class TestBitwardenKeyring(unittest.TestCase):
29
28
 
30
29
  @patch(target="keyring.get_credential", new=my_credential)
31
30
  def test_keyring_auth(self):
32
- node = DrbHttpNode(path=self.url_ok, auth=HTTPBasicAuth('usr', 'pwd'))
31
+ node = DrbHttpNode(path=self.url_ok)
33
32
 
34
33
  self.assertEqual('{"path": "/resources/test.txt"}',
35
34
  node.get_impl(io.BytesIO).getvalue().decode())