Bug with error handling: for now obi_errno needs to be passed to the
function handling errors and exceptions, as it can't read the right value of the global obi_errno (Cython configuration problem?)
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -33,10 +34,11 @@ cdef class Column_bool(Column):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef obibool_t value
|
||||
cdef object result
|
||||
value = obi_get_bool_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIBool_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -45,15 +47,17 @@ cdef class Column_bool(Column):
|
||||
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
if value is None :
|
||||
value = OBIBool_NA
|
||||
if obi_set_bool_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, <obibool_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_bool(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id) :
|
||||
global obi_errno
|
||||
cdef obibool_t value
|
||||
cdef object result
|
||||
cdef bytes elt_name
|
||||
@ -62,7 +66,7 @@ cdef class Column_multi_elts_bool(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_bool_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIBool_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -70,6 +74,7 @@ cdef class Column_multi_elts_bool(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef obibool_t value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -79,7 +84,7 @@ cdef class Column_multi_elts_bool(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_bool_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIBool_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -92,16 +97,17 @@ cdef class Column_multi_elts_bool(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value) :
|
||||
global obi_errno
|
||||
cdef bytes elt_name
|
||||
if value is None :
|
||||
value = OBIBool_NA
|
||||
if type(elt_id) == int :
|
||||
if obi_set_bool_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, <obibool_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_bool_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, <obibool_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
def register_class() :
|
||||
|
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -32,10 +33,11 @@ cdef class Column_char(Column):
|
||||
comments=comments)
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef obichar_t value
|
||||
cdef object result
|
||||
value = obi_get_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIChar_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -43,18 +45,20 @@ cdef class Column_char(Column):
|
||||
return result
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
cdef obichar_t value_b
|
||||
if value is None :
|
||||
value_b = OBIChar_NA
|
||||
else :
|
||||
value_b = <obichar_t> tobytes(value)[0]
|
||||
if obi_set_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_char(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id) :
|
||||
global obi_errno
|
||||
cdef obichar_t value
|
||||
cdef object result
|
||||
cdef bytes elt_name
|
||||
@ -63,7 +67,7 @@ cdef class Column_multi_elts_char(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_char_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIChar_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -71,6 +75,7 @@ cdef class Column_multi_elts_char(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef obichar_t value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -80,7 +85,7 @@ cdef class Column_multi_elts_char(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIChar_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -93,6 +98,7 @@ cdef class Column_multi_elts_char(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value) :
|
||||
global obi_errno
|
||||
cdef bytes elt_name
|
||||
cdef obichar_t value_b
|
||||
if value is None :
|
||||
@ -101,11 +107,11 @@ cdef class Column_multi_elts_char(Column_multi_elts):
|
||||
value_b = <obichar_t> tobytes(value)[0]
|
||||
if type(elt_id) == int :
|
||||
if obi_set_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, value_b) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_char_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, value_b) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
def register_class():
|
||||
|
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -31,29 +32,30 @@ cdef class Column_float(Column):
|
||||
elements_names=elements_names,
|
||||
comments=comments)
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef obifloat_t value
|
||||
cdef object result
|
||||
value = obi_get_float_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIFloat_NA :
|
||||
result = None
|
||||
else :
|
||||
result = <double> value
|
||||
return result
|
||||
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
if value is None :
|
||||
value = OBIFloat_NA
|
||||
if obi_set_float_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, <obifloat_t> value) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_float(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id) :
|
||||
global obi_errno
|
||||
cdef obifloat_t value
|
||||
cdef object result
|
||||
cdef bytes elt_name
|
||||
@ -62,7 +64,7 @@ cdef class Column_multi_elts_float(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_float_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIFloat_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -70,6 +72,7 @@ cdef class Column_multi_elts_float(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef obifloat_t value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -79,7 +82,7 @@ cdef class Column_multi_elts_float(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_float_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIFloat_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -92,16 +95,17 @@ cdef class Column_multi_elts_float(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value) :
|
||||
global obi_errno
|
||||
cdef bytes elt_name
|
||||
if value is None :
|
||||
value = OBIFloat_NA
|
||||
if type(elt_id) == int :
|
||||
if obi_set_float_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, <obifloat_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_float_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, <obifloat_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
def register_class():
|
||||
|
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -34,10 +35,11 @@ cdef class Column_int(Column):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef obiint_t value
|
||||
cdef object result
|
||||
value = obi_get_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIInt_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -46,15 +48,17 @@ cdef class Column_int(Column):
|
||||
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
if value is None :
|
||||
value = OBIInt_NA
|
||||
if obi_set_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, <obiint_t> value) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_int(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id) :
|
||||
global obi_errno
|
||||
cdef obiint_t value
|
||||
cdef object result
|
||||
cdef bytes elt_name
|
||||
@ -63,7 +67,7 @@ cdef class Column_multi_elts_int(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_int_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIInt_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -71,6 +75,7 @@ cdef class Column_multi_elts_int(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef obiint_t value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -80,7 +85,7 @@ cdef class Column_multi_elts_int(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIInt_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -93,16 +98,17 @@ cdef class Column_multi_elts_int(Column_multi_elts):
|
||||
return result
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value) :
|
||||
global obi_errno
|
||||
cdef bytes elt_name
|
||||
if value is None :
|
||||
value = OBIInt_NA
|
||||
if type(elt_id) == int :
|
||||
if obi_set_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, <obiint_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_int_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, <obiint_t> value) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
def register_class():
|
||||
|
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -40,11 +41,12 @@ cdef class Column_qual(Column):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef const uint8_t* value
|
||||
cdef int value_length
|
||||
cdef object result
|
||||
value = obi_get_qual_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, &value_length)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIQual_int_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -55,11 +57,12 @@ cdef class Column_qual(Column):
|
||||
|
||||
|
||||
cpdef object get_str_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef char* value
|
||||
cdef object result
|
||||
cdef int i
|
||||
value = obi_get_qual_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIQual_char_NA :
|
||||
result = None
|
||||
else : # TODO discuss
|
||||
@ -69,35 +72,38 @@ cdef class Column_qual(Column):
|
||||
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
cdef uint8_t* value_b
|
||||
cdef int value_length
|
||||
if value is None :
|
||||
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, OBIQual_int_NA, 0) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
value_length = len(value)
|
||||
value_b = <uint8_t*> malloc(value_length * sizeof(uint8_t))
|
||||
for i in range(value_length) :
|
||||
value_b[i] = <uint8_t>value[i]
|
||||
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, value_b, value_length) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
free(value_b)
|
||||
|
||||
|
||||
cpdef set_str_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
cdef bytes value_b
|
||||
if value is None :
|
||||
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, OBIQual_char_NA) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
value_b = tobytes(value)
|
||||
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id):
|
||||
global obi_errno
|
||||
cdef const uint8_t* value
|
||||
cdef int value_length
|
||||
cdef object result
|
||||
@ -107,7 +113,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_qual_int_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, &value_length)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIQual_int_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -118,6 +124,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef object get_str_item(self, index_t line_nb, object elt_id):
|
||||
global obi_errno
|
||||
cdef char* value
|
||||
cdef object result
|
||||
if type(elt_id) == int :
|
||||
@ -125,7 +132,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_qual_char_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIQual_char_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -135,6 +142,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef const uint8_t* value
|
||||
cdef int value_length
|
||||
cdef object value_in_result
|
||||
@ -146,7 +154,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_qual_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i, &value_length)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIQual_int_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -162,6 +170,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef object get_str_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef char* value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -171,7 +180,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_qual_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIQual_char_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -186,6 +195,7 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value):
|
||||
global obi_errno
|
||||
cdef uint8_t* value_b
|
||||
cdef int value_length
|
||||
cdef bytes elt_name
|
||||
@ -201,17 +211,18 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
if type(elt_id) == int :
|
||||
if obi_set_qual_int_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, value_b, value_length) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_qual_int_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, value_b, value_length) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
if value is not None :
|
||||
free(value_b)
|
||||
|
||||
|
||||
cpdef set_str_item(self, index_t line_nb, object elt_id, object value):
|
||||
global obi_errno
|
||||
cdef bytes value_b
|
||||
cdef bytes elt_name
|
||||
|
||||
@ -222,11 +233,11 @@ cdef class Column_multi_elts_qual(Column_multi_elts):
|
||||
|
||||
if type(elt_id) == int :
|
||||
if obi_set_qual_char_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, value_b) < 0 :
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_qual_char_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -34,10 +35,11 @@ cdef class Column_seq(Column):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef char* value
|
||||
cdef object result
|
||||
value = obi_get_seq_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBISeq_NA :
|
||||
result = None
|
||||
else : # TODO
|
||||
@ -49,6 +51,7 @@ cdef class Column_seq(Column):
|
||||
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
cdef char* value_b
|
||||
cdef bytes value_bytes
|
||||
|
||||
@ -59,12 +62,13 @@ cdef class Column_seq(Column):
|
||||
value_b = <char*>value_bytes
|
||||
|
||||
if obi_set_seq_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_seq(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id) :
|
||||
global obi_errno
|
||||
cdef char* value
|
||||
cdef object result
|
||||
if type(elt_id) == int :
|
||||
@ -72,7 +76,7 @@ cdef class Column_multi_elts_seq(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_seq_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBISeq_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -84,6 +88,7 @@ cdef class Column_multi_elts_seq(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef char* value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -93,7 +98,7 @@ cdef class Column_multi_elts_seq(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_seq_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBISeq_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -110,7 +115,7 @@ cdef class Column_multi_elts_seq(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value):
|
||||
|
||||
global obi_errno
|
||||
cdef bytes elt_name
|
||||
cdef char* value_b
|
||||
cdef bytes value_bytes
|
||||
@ -123,12 +128,12 @@ cdef class Column_multi_elts_seq(Column_multi_elts):
|
||||
|
||||
if type(elt_id) == int :
|
||||
if obi_set_seq_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_seq_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
def register_class():
|
||||
|
@ -1,5 +1,6 @@
|
||||
#cython: language_level=3
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno
|
||||
|
||||
from ..column cimport register_column_class
|
||||
|
||||
@ -32,10 +33,11 @@ cdef class Column_str(Column):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb):
|
||||
global obi_errno
|
||||
cdef const_char_p value
|
||||
cdef object result
|
||||
value = obi_get_str_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem getting a value from a column")
|
||||
if value == OBIStr_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -44,6 +46,7 @@ cdef class Column_str(Column):
|
||||
|
||||
|
||||
cpdef set_line(self, index_t line_nb, object value):
|
||||
global obi_errno
|
||||
cdef char* value_b
|
||||
cdef bytes value_bytes
|
||||
|
||||
@ -54,12 +57,13 @@ cdef class Column_str(Column):
|
||||
value_b = <char*>value_bytes
|
||||
|
||||
if obi_set_str_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, 0, value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=None, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
cdef class Column_multi_elts_str(Column_multi_elts):
|
||||
|
||||
cpdef object get_item(self, index_t line_nb, object elt_id) :
|
||||
global obi_errno
|
||||
cdef const_char_p value
|
||||
cdef object result
|
||||
if type(elt_id) == int :
|
||||
@ -67,7 +71,7 @@ cdef class Column_multi_elts_str(Column_multi_elts):
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
value = obi_get_str_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem getting a value from a column")
|
||||
if value == OBIStr_NA :
|
||||
result = None
|
||||
else :
|
||||
@ -76,6 +80,7 @@ cdef class Column_multi_elts_str(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef object get_line(self, index_t line_nb) :
|
||||
global obi_errno
|
||||
cdef const_char_p value
|
||||
cdef object value_in_result
|
||||
cdef dict result
|
||||
@ -85,7 +90,7 @@ cdef class Column_multi_elts_str(Column_multi_elts):
|
||||
all_NA = True
|
||||
for i in range(self.nb_elements_per_line) :
|
||||
value = obi_get_str_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, i)
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=i, error_message="Problem getting a value from a column")
|
||||
if value == OBIStr_NA :
|
||||
value_in_result = None
|
||||
else :
|
||||
@ -99,6 +104,7 @@ cdef class Column_multi_elts_str(Column_multi_elts):
|
||||
|
||||
|
||||
cpdef set_item(self, index_t line_nb, object elt_id, object value):
|
||||
global obi_errno
|
||||
cdef bytes elt_name
|
||||
cdef char* value_b
|
||||
cdef bytes value_bytes
|
||||
@ -111,11 +117,11 @@ cdef class Column_multi_elts_str(Column_multi_elts):
|
||||
|
||||
if type(elt_id) == int :
|
||||
if obi_set_str_with_elt_idx_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_id, <char*>value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
else :
|
||||
elt_name = tobytes(elt_id)
|
||||
if obi_set_str_with_elt_name_and_col_p_in_view(self._view.pointer(), self.pointer(), line_nb, elt_name, <char*>value_b) < 0:
|
||||
obi_errno_to_exception(line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
obi_errno_to_exception(obi_errno, line_nb=line_nb, elt_id=elt_id, error_message="Problem setting a value in a column")
|
||||
|
||||
|
||||
def register_class():
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
from obitools3.dms.capi.obitypes cimport obitype_t, index_t
|
||||
|
||||
cdef obi_errno_to_exception(index_t line_nb=*, object elt_id=*, str error_message=*)
|
||||
cdef obi_errno_to_exception(int obi_errno, index_t line_nb=*, object elt_id=*, str error_message=*)
|
||||
|
||||
cdef bytes str2bytes(str string)
|
||||
cdef str bytes2str(bytes string)
|
||||
|
@ -11,12 +11,12 @@ from obitools3.dms.capi.obitypes cimport is_a_DNA_seq, \
|
||||
OBI_STR, \
|
||||
index_t
|
||||
|
||||
from obitools3.dms.capi.obierrno cimport obi_errno, \
|
||||
OBI_LINE_IDX_ERROR, \
|
||||
from obitools3.dms.capi.obierrno cimport OBI_LINE_IDX_ERROR, \
|
||||
OBI_ELT_IDX_ERROR
|
||||
#obi_errno
|
||||
|
||||
|
||||
cdef obi_errno_to_exception(index_t line_nb=-1, object elt_id=None, str error_message=None) :
|
||||
cdef obi_errno_to_exception(int obi_errno, index_t line_nb=-1, object elt_id=None, str error_message=None) :
|
||||
global obi_errno
|
||||
if obi_errno > 0 :
|
||||
if obi_errno == OBI_LINE_IDX_ERROR :
|
||||
|
Reference in New Issue
Block a user