Skip to content

Commit

Permalink
minor updates to portal_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
dmichaels-harvard committed Nov 8, 2024
1 parent 29a7b1b commit b5a4032
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions dcicutils/portal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from requests.models import Response
from threading import Thread
from typing import Callable, Dict, List, Optional, Tuple, Type, Union
# from urllib.parse import parse_qs as parse_url_query_string
from uuid import uuid4 as uuid
from webtest.app import TestApp, TestResponse
from wsgiref.simple_server import make_server as wsgi_make_server
Expand Down Expand Up @@ -279,6 +280,8 @@ def get_metadata(self, object_id: str, raw: bool = False, database: bool = False
limit: Optional[int] = None, offset: Optional[int] = None,
field: Optional[str] = None, deleted: bool = False,
raise_exception: bool = True) -> Optional[dict]:
if not isinstance(object_id, str):
return None
if isinstance(raw, bool) and raw:
add_on = "frame=raw" + ("&datastore=database" if isinstance(database, bool) and database else "")
elif database:
Expand All @@ -305,6 +308,13 @@ def get_metadata(self, object_id: str, raw: bool = False, database: bool = False
add_on += "&status=deleted"
else:
add_on += "status=deleted"
if (question_mark := object_id.find("?")) > 0:
query_string = object_id[question_mark + 1:]
object_id = object_id[:question_mark]
if add_on:
add_on += f"&{query_string}"
else:
add_on += query_string
if raise_exception:
return get_metadata(obj_id=object_id, vapp=self.vapp, key=self.key, add_on=add_on)
else:
Expand Down

0 comments on commit b5a4032

Please sign in to comment.