From 123e5dc0ac8568c24fa5d4f399021b3f21e8b5bd Mon Sep 17 00:00:00 2001 From: Celine Mercier Date: Wed, 31 Oct 2018 14:45:17 +0100 Subject: [PATCH] Cython URI API: added an argument to only open the DMS and return the rest as a character string --- python/obitools3/uri/decode.pyx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 python/obitools3/uri/decode.pyx diff --git a/python/obitools3/uri/decode.pyx b/python/obitools3/uri/decode.pyx old mode 100644 new mode 100755 index 0e5df55..74d44d7 --- a/python/obitools3/uri/decode.pyx +++ b/python/obitools3/uri/decode.pyx @@ -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