Cython URI API: added an argument to only open the DMS and return the

rest as a character string
This commit is contained in:
Celine Mercier
2018-10-31 14:45:17 +01:00
parent 320561a582
commit 123e5dc0ac

10
python/obitools3/uri/decode.pyx Normal file → Executable file
View File

@ -162,7 +162,8 @@ Reads an URI and returns a tuple containing:
'''
def open_uri(uri,
bint input=True,
type newviewtype=View):
type newviewtype=View,
dms_only=False):
cdef bytes urib = tobytes(uri)
cdef bytes scheme
@ -200,6 +201,11 @@ def open_uri(uri,
dms=(default_dms, urip.path)
if dms is not None:
if dms_only:
return (dms[0],
dms[1],
type(dms[1]),
urlunparse(urip))
try:
resource=open_dms_element(dms[0],
dms[1],
@ -229,7 +235,7 @@ def open_uri(uri,
if scheme==b"dms" :
logger('Error','Could not open DMS URI: %s', uri)
raise FileNotFoundError('uri')
raise FileNotFoundError()
if not urip.scheme:
urib=b"file:"+urib