diff --git a/python/obitools3/obidms/_obidms.pxd b/python/obitools3/obidms/_obidms.pxd index 386d672..b0e8312 100644 --- a/python/obitools3/obidms/_obidms.pxd +++ b/python/obitools3/obidms/_obidms.pxd @@ -14,7 +14,7 @@ cdef class OBIDMS: cdef str dms_name cpdef dict list(self) - + cpdef close(self) cpdef OBIDMS_column open_column(self, str column_name, bint create=*, @@ -35,7 +35,7 @@ cdef class OBIDMS_column: cdef str column_name cpdef object get_item(self, size_t line_nb, str element_name) -# cpdef set_item(self, size_t line_nb, str element_name, object value) TODO +# cpdef set_item(self, size_t line_nb, str element_name, object value) TODO can't declare because object value cpdef list get_elements_names(self) cpdef str get_data_type(self) cpdef size_t get_nb_lines_used(self) diff --git a/python/obitools3/obidms/_obidms.pyx b/python/obitools3/obidms/_obidms.pyx index 7c90544..83d4fc7 100644 --- a/python/obitools3/obidms/_obidms.pyx +++ b/python/obitools3/obidms/_obidms.pyx @@ -4,7 +4,8 @@ from pathlib import Path from obitools3.utils cimport bytes2str, str2bytes -from .capi.obidms cimport obi_dms +from .capi.obidms cimport obi_dms, \ + obi_close_dms from .capi.obidmscolumn cimport obi_column_get_data_type_from_name, \ obi_column_get_latest_version_from_name, \ obi_column_get_line_count_from_name, \ @@ -51,10 +52,13 @@ cdef class OBIDMS : # Fill structure and create or open the DMS self.dms_name = dms_name self.pointer = obi_dms( dms_name_b) + # TODO: test pointer and raise Exception("Failed opening or creating an OBIDMS") -# def __del__(self) : # TODO problem with closing dir breaking everything -# obi_close_dms(self.pointer) + cpdef close(self) : + #TODO close all columns + if (obi_close_dms(self.pointer)) < 0 : + raise Exception("Problem closing an OBIDMS") cpdef dict list(self): @@ -121,10 +125,7 @@ cdef class OBIDMS : else : data_type = obi_column_get_data_type_from_name(self.pointer, column_name_b) - # Open the column with the right subclass depending on the data type and the mode (read-only or writable) - - # TODO : check that data type is the same as previous version if it exists? - + # Open the column with the right subclass depending on the data type and the mode (read-only or writable) if data_type == 1 : if (create or clone) : column = OBIDMS_column_int_writable(self, column_name,