Functions to truncate and/or close a column
This commit is contained in:
@ -34,6 +34,7 @@ cdef extern from "obidmscolumn.h" nogil:
|
||||
int obi_close_column(OBIDMS_column_p column)
|
||||
OBIType_t obi_column_get_data_type_from_name(OBIDMS_p dms, const char* column_name)
|
||||
OBIDMS_column_p obi_clone_column(OBIDMS_p dms, const char* column_name, obiversion_t version_number, bint clone_data)
|
||||
int obi_truncate_and_close_column(OBIDMS_column_p column)
|
||||
|
||||
|
||||
cdef class OBIDMS_column:
|
||||
|
@ -65,11 +65,7 @@ cdef class OBIDMS_column:
|
||||
|
||||
def get_data_type(self):
|
||||
return self.data_type
|
||||
|
||||
# def __del__(self):
|
||||
# if obi_close_column(self.pointer) != 0 :
|
||||
# raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
@staticmethod
|
||||
def open(dms_name, column_name,
|
||||
create=False, clone=False, clone_data=True,
|
||||
|
@ -13,11 +13,20 @@ cdef class OBIDMS_column_bool_read(OBIDMS_column_bool) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
raise Exception('Column is read-only')
|
||||
|
||||
def close(self):
|
||||
if obi_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
cdef class OBIDMS_column_bool_writable(OBIDMS_column_bool) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
return obi_column_set_bool_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'), value)
|
||||
|
||||
|
||||
def close(self):
|
||||
if obi_truncate_and_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
|
@ -8,16 +8,25 @@ cdef class OBIDMS_column_char(OBIDMS_column) :
|
||||
def get_item(self, line_nb, element_name):
|
||||
return (obi_column_get_char_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'))).decode(encoding='utf-8')[:1]
|
||||
|
||||
|
||||
cdef class OBIDMS_column_char_read(OBIDMS_column_char) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
raise Exception('Column is read-only')
|
||||
|
||||
def close(self):
|
||||
if obi_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
cdef class OBIDMS_column_char_writable(OBIDMS_column_char) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
return obi_column_set_char_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'), value.encode('utf-8'))
|
||||
|
||||
def close(self):
|
||||
if obi_truncate_and_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
|
@ -8,15 +8,24 @@ cdef class OBIDMS_column_float(OBIDMS_column) :
|
||||
def get_item(self, line_nb, element_name):
|
||||
return obi_column_get_float_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'))
|
||||
|
||||
|
||||
cdef class OBIDMS_column_float_read(OBIDMS_column_float) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
raise Exception('Column is read-only')
|
||||
|
||||
def close(self):
|
||||
if obi_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
cdef class OBIDMS_column_float_writable(OBIDMS_column_float) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
return obi_column_set_float_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'), value)
|
||||
|
||||
def close(self):
|
||||
if obi_truncate_and_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
@ -7,15 +7,24 @@ cdef class OBIDMS_column_idx(OBIDMS_column) :
|
||||
|
||||
def get_item(self, line_nb, element_name):
|
||||
return obi_column_get_idx_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'))
|
||||
|
||||
|
||||
cdef class OBIDMS_column_idx_read(OBIDMS_column_idx) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
raise Exception('Column is read-only')
|
||||
|
||||
def close(self):
|
||||
if obi_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
cdef class OBIDMS_column_idx_writable(OBIDMS_column_idx) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
return obi_column_set_idx_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'), value)
|
||||
|
||||
def close(self):
|
||||
if obi_truncate_and_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
@ -13,10 +13,18 @@ cdef class OBIDMS_column_int_read(OBIDMS_column_int) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
raise Exception('Column is read-only')
|
||||
|
||||
|
||||
def close(self):
|
||||
if obi_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
||||
|
||||
cdef class OBIDMS_column_int_writable(OBIDMS_column_int) :
|
||||
|
||||
def set_item(self, line_nb, element_name, value):
|
||||
return obi_column_set_int_with_elt_name(self.pointer, line_nb, element_name.encode('utf-8'), value)
|
||||
|
||||
def close(self):
|
||||
if obi_truncate_and_close_column(self.pointer) < 0 :
|
||||
raise Exception("Problem closing a column")
|
||||
|
Reference in New Issue
Block a user