bacdive 1.0.0__py3-none-any.whl → 2.0.0__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.
.DS_Store ADDED
Binary file
bacdive/client.py CHANGED
@@ -1,13 +1,8 @@
1
1
  '''
2
- Using the BacDive API requires registration. Registrations is free but the
3
- usage of BacDive data is only permitted when in compliance with the BacDive
4
- terms of use. See https://bacdive.dsmz.de/about for details.
5
-
6
- Please register at https://api.bacdive.dsmz.de/login.
2
+ This package is for using the BacDive API V2 (2026-02).
3
+ Registration is not required anymore.
7
4
  '''
8
5
 
9
- from keycloak.exceptions import KeycloakAuthenticationError, KeycloakPostError, KeycloakConnectionError
10
- from keycloak import KeycloakOpenID
11
6
  from requests.adapters import HTTPAdapter
12
7
  from urllib3.util.retry import Retry
13
8
  import requests
@@ -29,7 +24,7 @@ class ReportRetry(Retry):
29
24
 
30
25
 
31
26
  class BacdiveClient():
32
- def __init__(self, user, password, public=True, max_retries=10, retry_delay=50, request_timeout=300):
27
+ def __init__(self, user=None, password=None, public=True, max_retries=10, retry_delay=50, request_timeout=300):
33
28
  ''' Initialize client and authenticate on the server '''
34
29
  self.result = {}
35
30
  self.public = public
@@ -46,32 +41,6 @@ class BacdiveClient():
46
41
  else:
47
42
  server_url = "https://sso.dmz.dsmz.de/auth/"
48
43
 
49
- self.keycloak_openid = KeycloakOpenID(
50
- server_url=server_url,
51
- client_id=client_id,
52
- realm_name="dsmz")
53
-
54
- for _ in range(self.max_retries):
55
- try:
56
- # Get tokens
57
- token = self.keycloak_openid.token(user, password)
58
- self.access_token = token['access_token']
59
- self.refresh_token = token['refresh_token']
60
- print("-- Authentication successful --")
61
- except KeycloakAuthenticationError as e:
62
- print(f"ERROR - Keycloak Authentication failed: {e}\n Retrying in {self.retry_delay} seconds")
63
- time.sleep(self.retry_delay)
64
- except KeycloakConnectionError as e:
65
- print(f"ERROR - Keycloak Connection failed: {e}\n Retrying in {self.retry_delay} seconds")
66
- time.sleep(self.retry_delay)
67
- except KeycloakPostError as e:
68
- print(f"ERROR - Keycloak Connection failed: {e}\n Retrying in {self.retry_delay} seconds")
69
- time.sleep(self.retry_delay)
70
- else:
71
- break # break loop if successful
72
- else:
73
- print(f"ERROR - Keycloak authentication failed after {self.max_retries} retries.")
74
-
75
44
  def includePredictions(self):
76
45
  self.predictions = True
77
46
 
@@ -92,9 +61,9 @@ class BacdiveClient():
92
61
  def do_api_call(self, url):
93
62
  ''' Initialize API call on given URL and returns result as json '''
94
63
  if self.public:
95
- baseurl = "https://api.bacdive.dsmz.de/"
64
+ baseurl = "https://api.bacdive.dsmz.de/v2/"
96
65
  else:
97
- baseurl = "http://api.bacdive-dev.dsmz.local/"
66
+ baseurl = "http://api.bacdive-dev.dsmz.local/v2/"
98
67
 
99
68
  if not url.startswith("http"):
100
69
  # if base is missing add default:
@@ -107,23 +76,14 @@ class BacdiveClient():
107
76
  elif (resp.status_code == 401):
108
77
  msg = json.loads(resp.content)
109
78
 
110
- if msg['message'] == "Expired token":
111
- # Access token might have expired (15 minutes life time).
112
- # Get new tokens using refresh token and try again.
113
- token = self.keycloak_openid.refresh_token(self.refresh_token)
114
- self.access_token = token['access_token']
115
- self.refresh_token = token['refresh_token']
116
- return self.do_api_call(url)
117
-
118
79
  return msg
119
80
  else:
120
81
  return json.loads(resp.content)
121
82
 
122
83
  def do_request(self, url):
123
- ''' Perform request with authentication '''
84
+ ''' Perform request'''
124
85
  headers = {
125
86
  "Accept": "application/json",
126
- "Authorization": "Bearer {token}".format(token=self.access_token)
127
87
  }
128
88
 
129
89
  if self.predictions:
@@ -163,7 +123,7 @@ class BacdiveClient():
163
123
  def retrieve(self, filter=None):
164
124
  ''' Yields all the received entries and does next call if result is incomplete '''
165
125
  ids = ";".join([str(i) for i in self.result['results']])
166
- entries = self.do_api_call('fetch/'+ids)['results']
126
+ entries = self.do_api_call('fetch/'+ids)['results'] if ids else []
167
127
  for el in entries:
168
128
  if isinstance(el, dict):
169
129
  entry = el
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: bacdive
3
- Version: 1.0.0
3
+ Version: 2.0.0
4
4
  Summary: BacDive-API - Programmatic Access to the BacDive Database
5
5
  Home-page: https://bacdive.dsmz.de/
6
6
  Author: Julia Koblitz
@@ -13,23 +13,28 @@ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
13
13
  Requires-Python: >=3.6
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
- Requires-Dist: python-keycloak
17
- Requires-Dist: requests >=2.25.1
18
- Requires-Dist: urllib3 >=1.26.5
19
-
20
- # BacDive API
21
-
22
- Using the BacDive API requires registration. Registration is free but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See [About BacDive](https://bacdive.dsmz.de/about) for details.
23
-
24
- Please register [here](https://api.bacdive.dsmz.de/login).
25
-
26
- The Python package can be initialized using your login credentials:
27
-
16
+ Requires-Dist: requests>=2.25.1
17
+ Requires-Dist: urllib3>=1.26.5
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: keywords
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # BacDive API v2
31
+
32
+ Using the BacDive API does not require registration anymore, but the usage of BacDive data is only permitted when in compliance with the BacDive terms of use. See [About BacDive](https://bacdive.dsmz.de/about) for details.
28
33
 
29
34
  ```python
30
35
  import bacdive
31
36
 
32
- client = bacdive.BacdiveClient('name@mail.example', 'password')
37
+ client = bacdive.BacdiveClient()
33
38
 
34
39
  # [optional] You may define the search type as one of the following:
35
40
  # 'exact' (default), 'contains', 'startswith', 'endswith'
@@ -0,0 +1,8 @@
1
+ .DS_Store,sha256=6kR8yA9s9_CWzDhydpvo0tm6-DKqdlejyWlPP6LyccY,8196
2
+ bacdive/__init__.py,sha256=m_PQ86KbAxoaj6q4ZhZghe4k4clRTHj6jgtBuQxl5Gs,33
3
+ bacdive/client.py,sha256=L0k98YF6xtEcAPEEQmE6gP_wk_c1UMfvCws7UPh9jZY,9957
4
+ bacdive-2.0.0.dist-info/licenses/LICENSE,sha256=5wPFG6uBYvOHGR5R3n3AI3SpYOY1ODbY8lHGOXM6Mt8,1142
5
+ bacdive-2.0.0.dist-info/METADATA,sha256=qDEIOcDG6jmsEHyUHQMSdMmEIMFTZYrIdFIFectggYw,5292
6
+ bacdive-2.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
7
+ bacdive-2.0.0.dist-info/top_level.txt,sha256=_lfFGIEO4Y9K0ky5sUVKRn_iijFQfdHzR7L-jSqkW8U,8
8
+ bacdive-2.0.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,7 +0,0 @@
1
- bacdive/__init__.py,sha256=m_PQ86KbAxoaj6q4ZhZghe4k4clRTHj6jgtBuQxl5Gs,33
2
- bacdive/client.py,sha256=-WlZ6yBnYNMpbGTfp4m5jGDhTaYYCkPcFU3dmE-7mGQ,12034
3
- bacdive-1.0.0.dist-info/LICENSE,sha256=5wPFG6uBYvOHGR5R3n3AI3SpYOY1ODbY8lHGOXM6Mt8,1142
4
- bacdive-1.0.0.dist-info/METADATA,sha256=L88CrUtvQfSaADLllt0oyGXw5a1wp2hUWMKv14LF36U,5251
5
- bacdive-1.0.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
6
- bacdive-1.0.0.dist-info/top_level.txt,sha256=_lfFGIEO4Y9K0ky5sUVKRn_iijFQfdHzR7L-jSqkW8U,8
7
- bacdive-1.0.0.dist-info/RECORD,,