Method to close a DMS is uncommented but not complete yet (columns have

to be closed separately)
This commit is contained in:
Celine Mercier
2015-10-08 10:44:13 +02:00
parent ee4c513fd4
commit b553eef781
2 changed files with 10 additions and 9 deletions

View File

@ -14,7 +14,7 @@ cdef class OBIDMS:
cdef str dms_name cdef str dms_name
cpdef dict list(self) cpdef dict list(self)
cpdef close(self)
cpdef OBIDMS_column open_column(self, cpdef OBIDMS_column open_column(self,
str column_name, str column_name,
bint create=*, bint create=*,
@ -35,7 +35,7 @@ cdef class OBIDMS_column:
cdef str column_name cdef str column_name
cpdef object get_item(self, size_t line_nb, str element_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 list get_elements_names(self)
cpdef str get_data_type(self) cpdef str get_data_type(self)
cpdef size_t get_nb_lines_used(self) cpdef size_t get_nb_lines_used(self)

View File

@ -4,7 +4,8 @@ from pathlib import Path
from obitools3.utils cimport bytes2str, str2bytes 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, \ from .capi.obidmscolumn cimport obi_column_get_data_type_from_name, \
obi_column_get_latest_version_from_name, \ obi_column_get_latest_version_from_name, \
obi_column_get_line_count_from_name, \ obi_column_get_line_count_from_name, \
@ -51,10 +52,13 @@ cdef class OBIDMS :
# Fill structure and create or open the DMS # Fill structure and create or open the DMS
self.dms_name = dms_name self.dms_name = dms_name
self.pointer = obi_dms(<const_char_p> dms_name_b) self.pointer = obi_dms(<const_char_p> 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 cpdef close(self) :
# obi_close_dms(self.pointer) #TODO close all columns
if (obi_close_dms(self.pointer)) < 0 :
raise Exception("Problem closing an OBIDMS")
cpdef dict list(self): cpdef dict list(self):
@ -121,10 +125,7 @@ cdef class OBIDMS :
else : else :
data_type = obi_column_get_data_type_from_name(self.pointer, column_name_b) 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) # 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?
if data_type == 1 : if data_type == 1 :
if (create or clone) : if (create or clone) :
column = OBIDMS_column_int_writable(self, column_name, column = OBIDMS_column_int_writable(self, column_name,