Cython URI API: added an argument to only open the DMS and return the
rest as a character string
This commit is contained in:
10
python/obitools3/uri/decode.pyx
Normal file → Executable file
10
python/obitools3/uri/decode.pyx
Normal file → Executable file
@ -162,7 +162,8 @@ Reads an URI and returns a tuple containing:
|
|||||||
'''
|
'''
|
||||||
def open_uri(uri,
|
def open_uri(uri,
|
||||||
bint input=True,
|
bint input=True,
|
||||||
type newviewtype=View):
|
type newviewtype=View,
|
||||||
|
dms_only=False):
|
||||||
|
|
||||||
cdef bytes urib = tobytes(uri)
|
cdef bytes urib = tobytes(uri)
|
||||||
cdef bytes scheme
|
cdef bytes scheme
|
||||||
@ -200,6 +201,11 @@ def open_uri(uri,
|
|||||||
dms=(default_dms, urip.path)
|
dms=(default_dms, urip.path)
|
||||||
|
|
||||||
if dms is not None:
|
if dms is not None:
|
||||||
|
if dms_only:
|
||||||
|
return (dms[0],
|
||||||
|
dms[1],
|
||||||
|
type(dms[1]),
|
||||||
|
urlunparse(urip))
|
||||||
try:
|
try:
|
||||||
resource=open_dms_element(dms[0],
|
resource=open_dms_element(dms[0],
|
||||||
dms[1],
|
dms[1],
|
||||||
@ -229,7 +235,7 @@ def open_uri(uri,
|
|||||||
|
|
||||||
if scheme==b"dms" :
|
if scheme==b"dms" :
|
||||||
logger('Error','Could not open DMS URI: %s', uri)
|
logger('Error','Could not open DMS URI: %s', uri)
|
||||||
raise FileNotFoundError('uri')
|
raise FileNotFoundError()
|
||||||
|
|
||||||
if not urip.scheme:
|
if not urip.scheme:
|
||||||
urib=b"file:"+urib
|
urib=b"file:"+urib
|
||||||
|
Reference in New Issue
Block a user