dcicutils 8.16.2__py3-none-any.whl → 8.16.2.1b2__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
dcicutils/portal_utils.py CHANGED
@@ -209,8 +209,25 @@ class Portal:
209
209
  return self._vapp
210
210
 
211
211
  def get(self, url: str, follow: bool = True,
212
- raw: bool = False, database: bool = False, raise_for_status: bool = False, **kwargs) -> OptionalResponse:
212
+ raw: bool = False, database: bool = False,
213
+ limit: Optional[int] = None, offset: Optional[int] = None, field: Optional[str] = None,
214
+ raise_for_status: bool = False, **kwargs) -> OptionalResponse:
213
215
  url = self.url(url, raw, database)
216
+ if isinstance(limit, int) and (limit >= 0):
217
+ if "?" in url:
218
+ url += f"&limit={limit}"
219
+ else:
220
+ url += f"?limit={limit}"
221
+ if isinstance(offset, int) and (offset >= 0):
222
+ if "?" in url:
223
+ url += f"&from={offset}"
224
+ else:
225
+ url += f"?from={offset}"
226
+ if isinstance(field, str) and field:
227
+ if "?" in url:
228
+ url += f"&field={field}"
229
+ else:
230
+ url += f"?field={field}"
214
231
  if not self.vapp:
215
232
  response = requests.get(url, allow_redirects=follow, **self._kwargs(**kwargs))
216
233
  else:
@@ -252,14 +269,30 @@ class Portal:
252
269
  response.raise_for_status()
253
270
  return response
254
271
 
255
- def get_metadata(self, object_id: str, raw: bool = False,
256
- database: bool = False, raise_exception: bool = True) -> Optional[dict]:
272
+ def get_metadata(self, object_id: str, raw: bool = False, database: bool = False,
273
+ limit: Optional[int] = None, offset: Optional[int] = None, field: Optional[str] = None,
274
+ raise_exception: bool = True) -> Optional[dict]:
257
275
  if isinstance(raw, bool) and raw:
258
276
  add_on = "frame=raw" + ("&datastore=database" if isinstance(database, bool) and database else "")
259
277
  elif database:
260
278
  add_on = "datastore=database"
261
279
  else:
262
280
  add_on = ""
281
+ if isinstance(limit, int) and (limit >= 0):
282
+ if add_on:
283
+ add_on += f"&limit={limit}"
284
+ else:
285
+ add_on += f"limit={limit}"
286
+ if isinstance(offset, int) and (offset >= 0):
287
+ if add_on:
288
+ add_on += f"&from={offset}"
289
+ else:
290
+ add_on += f"from={offset}"
291
+ if isinstance(field, int) and field:
292
+ if add_on:
293
+ add_on += f"&field={field}"
294
+ else:
295
+ add_on += f"field={field}"
263
296
  if raise_exception:
264
297
  return get_metadata(obj_id=object_id, vapp=self.vapp, key=self.key, add_on=add_on)
265
298
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dcicutils
3
- Version: 8.16.2
3
+ Version: 8.16.2.1b2
4
4
  Summary: Utility package for interacting with the 4DN Data Portal and other 4DN resources
5
5
  Home-page: https://github.com/4dn-dcic/utils
6
6
  License: MIT
@@ -49,7 +49,7 @@ dcicutils/misc_utils.py,sha256=xNQtavXS6vw_x9rQNhZEryo9b19oWYg-A8TzjhVDuxg,11594
49
49
  dcicutils/obfuscation_utils.py,sha256=fo2jOmDRC6xWpYX49u80bVNisqRRoPskFNX3ymFAmjw,5963
50
50
  dcicutils/opensearch_utils.py,sha256=V2exmFYW8Xl2_pGFixF4I2Cc549Opwe4PhFi5twC0M8,1017
51
51
  dcicutils/portal_object_utils.py,sha256=Az3n1aL-PQkN5gOFE6ZqC2XkYsqiwKlq7-tZggs1QN4,11062
52
- dcicutils/portal_utils.py,sha256=4mHNdMcaQDUVPfiDYwGeIqjerNuDRnNloUDIZl41r9g,45439
52
+ dcicutils/portal_utils.py,sha256=0bvqHNSXyS9ceTf9mAUKQnH9eX0yj8GIMy6RE3D-pzo,46727
53
53
  dcicutils/progress_bar.py,sha256=R3bWLMYM3Xq9PY7U0JadcFT1m7QmCbrbDp9qs9_Kf_c,19472
54
54
  dcicutils/project_utils.py,sha256=qPdCaFmWUVBJw4rw342iUytwdQC0P-XKpK4mhyIulMM,31250
55
55
  dcicutils/qa_checkers.py,sha256=j0kzo_T5VduKTxgsMTp7xjneyNokumZzI_iz55Y0Jjs,20505
@@ -75,8 +75,8 @@ dcicutils/trace_utils.py,sha256=g8kwV4ebEy5kXW6oOrEAUsurBcCROvwtZqz9fczsGRE,1769
75
75
  dcicutils/validation_utils.py,sha256=cMZIU2cY98FYtzK52z5WUYck7urH6JcqOuz9jkXpqzg,14797
76
76
  dcicutils/variant_utils.py,sha256=2H9azNx3xAj-MySg-uZ2SFqbWs4kZvf61JnK6b-h4Qw,4343
77
77
  dcicutils/zip_utils.py,sha256=_Y9EmL3D2dUZhxucxHvrtmmlbZmK4FpSsHEb7rGSJLU,3265
78
- dcicutils-8.16.2.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
79
- dcicutils-8.16.2.dist-info/METADATA,sha256=LlYTeoPfWMviVT84rMKD3MnzO3aTFKTVvtLvBn1mibE,3489
80
- dcicutils-8.16.2.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
81
- dcicutils-8.16.2.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
82
- dcicutils-8.16.2.dist-info/RECORD,,
78
+ dcicutils-8.16.2.1b2.dist-info/LICENSE.txt,sha256=qnwSmfnEWMl5l78VPDEzAmEbLVrRqQvfUQiHT0ehrOo,1102
79
+ dcicutils-8.16.2.1b2.dist-info/METADATA,sha256=yn_rs-2NS5azpUggsK705tPBPbwVBodQFvvz4kOD_4o,3493
80
+ dcicutils-8.16.2.1b2.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
81
+ dcicutils-8.16.2.1b2.dist-info/entry_points.txt,sha256=W6kEWdUJk9tQ4myAgpehPdebcwvCAZ7UgB-wyPgDUMg,335
82
+ dcicutils-8.16.2.1b2.dist-info/RECORD,,