## Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending#""" Tools for resolving Uniform Resource Identifiers (URIs) into objects. """fromtypingimportAnyimportjpyfromdeephavenimportDHErrorfromdeephaven._wrapperimportJObjectWrapper,wrap_j_object_JResolveTools=jpy.get_type("io.deephaven.uri.ResolveTools")
[docs]defresolve(uri:str)->Any:"""Resolves a Uniform Resource Identifier (URI) string into an object. Objects with custom Python wrappers, like Table, return an instance of the wrapper class; otherwise, the Java or Python object is returned. Args: uri (str): a URI string Returns: an object Raises: DHError """try:# When grabbing something out of the query scope, it may already be presented as a PyObject; in which case,# when the value gets back into python, it's a native python type - in which case, we don't need to wrap it.item=_JResolveTools.resolve(uri)returnwrap_j_object(item)ifisinstance(item,jpy.JType)elseitemexceptExceptionase:raiseDHError(e,"failed to resolve the URI.")frome