Added functions to try to open a DMS if it exists

This commit is contained in:
Celine Mercier
2017-07-05 15:38:22 +02:00
parent f5e992abbf
commit cb5ad2ed2d
4 changed files with 54 additions and 3 deletions

View File

@ -9,8 +9,9 @@ cdef extern from "obidms.h" nogil:
ctypedef OBIDMS_t* OBIDMS_p
OBIDMS_p obi_dms(const_char_p dms_name)
OBIDMS_p obi_open_dms(const char* dms_path)
OBIDMS_p obi_create_dms(const char* dms_path)
OBIDMS_p obi_open_dms(const_char_p dms_path)
OBIDMS_p obi_test_open_dms(const_char_p dms_path)
OBIDMS_p obi_create_dms(const_char_p dms_path)
int obi_close_dms(OBIDMS_p dms)
char* obi_dms_get_dms_path(OBIDMS_p dms)
char* obi_dms_get_full_path(OBIDMS_p dms, const_char_p path_name)

View File

@ -5,6 +5,7 @@ from libc.stdlib cimport free
from cpython.list cimport PyList_Size
from .capi.obidms cimport obi_open_dms, \
obi_test_open_dms, \
obi_create_dms, \
obi_close_dms, \
obi_dms_get_full_path
@ -52,6 +53,18 @@ cdef class DMS(OBIWrapper):
dms = OBIWrapper.new(DMS, pointer)
return dms
@staticmethod
def test_open(object dms_name) :
cdef OBIDMS_p pointer
cdef DMS dms
cdef bytes dms_name_b = tobytes(dms_name)
pointer = obi_test_open_dms(<const_char_p> dms_name_b)
if pointer == NULL :
raise Exception("Failed opening an OBIDMS")
dms = OBIWrapper.new(DMS, pointer)
return dms
def close(self) :
'''