NA value for OBI_STR and OBI_SEQ columns is now NULL

This commit is contained in:
Celine Mercier
2016-06-03 18:53:22 +02:00
parent a8ed57dc6e
commit 69bf7ec2e7
4 changed files with 13 additions and 15 deletions

View File

@ -32,7 +32,7 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
value = obi_column_get_obiqual_int_with_elt_idx_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0, &value_length)
if obi_errno > 0 :
raise IndexError(line_nb)
if value == NULL : # TODO
if value == OBIQual_int_NA :
result = None
else :
result = []
@ -47,7 +47,7 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
value = obi_column_get_obiqual_char_with_elt_idx_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if strcmp(value, OBIQual_char_NA) == 0 :
if value == OBIQual_char_NA :
result = None
else :
result = bytes2str(value)
@ -58,7 +58,7 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
cdef uint8_t* value_b
cdef int value_length
if value is None :
value_b = NULL # TODO
value_b = OBIQual_int_NA
value_length = 0
else :
value_length = len(value)
@ -80,7 +80,7 @@ cdef class OBIDMS_column_qual(OBIDMS_column):
raise Exception("Problem setting a value in a column")
# TODO OR NOT?
# TODO
# cdef class OBIDMS_column_multi_elts_qual(OBIDMS_column_multi_elts):
#
#

View File

@ -13,7 +13,6 @@ from ._obidms cimport OBIView
from obitools3.utils cimport str2bytes, bytes2str
from libc.stdlib cimport free
from libc.string cimport strcmp
cdef class OBIDMS_column_seq(OBIDMS_column):
@ -24,7 +23,7 @@ cdef class OBIDMS_column_seq(OBIDMS_column):
value = obi_column_get_obiseq_with_elt_idx_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if strcmp(value, OBISeq_NA) == 0 :
if value == OBISeq_NA :
result = None
else :
result = bytes2str(value)
@ -61,7 +60,7 @@ cdef class OBIDMS_column_multi_elts_seq(OBIDMS_column_multi_elts):
value = obi_column_get_obiseq_with_elt_name_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
if obi_errno > 0 :
raise IndexError(line_nb, element_name)
if strcmp(value, OBISeq_NA) == 0 :
if value == OBISeq_NA :
result = None
else :
result = bytes2str(value)
@ -80,7 +79,7 @@ cdef class OBIDMS_column_multi_elts_seq(OBIDMS_column_multi_elts):
value = obi_column_get_obiseq_with_elt_idx_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
if strcmp(value, OBISeq_NA) == 0 :
if value == OBISeq_NA :
value_in_result = None
else :
value_in_result = bytes2str(value)

View File

@ -9,8 +9,6 @@ from .capi.obitypes cimport OBIStr_NA, const_char_p
from obitools3.utils cimport str2bytes, bytes2str
from libc.string cimport strcmp
cdef class OBIDMS_column_str(OBIDMS_column):
@ -20,7 +18,7 @@ cdef class OBIDMS_column_str(OBIDMS_column):
value = obi_column_get_obistr_with_elt_idx_in_view(self.view.pointer, (self.pointer)[0], line_nb, 0)
if obi_errno > 0 :
raise IndexError(line_nb)
if strcmp(value, OBIStr_NA) == 0 :
if value == OBIStr_NA :
result = None
else :
result = bytes2str(value)
@ -45,7 +43,7 @@ cdef class OBIDMS_column_multi_elts_str(OBIDMS_column_multi_elts):
value = obi_column_get_obistr_with_elt_name_in_view(self.view.pointer, (self.pointer)[0], line_nb, str2bytes(element_name))
if obi_errno > 0 :
raise IndexError(line_nb, element_name)
if strcmp(value, OBIStr_NA) == 0 :
if value == OBIStr_NA :
result = None
else :
result = bytes2str(value)
@ -64,7 +62,7 @@ cdef class OBIDMS_column_multi_elts_str(OBIDMS_column_multi_elts):
value = obi_column_get_obistr_with_elt_idx_in_view(self.view.pointer, (self.pointer)[0], line_nb, i)
if obi_errno > 0 :
raise IndexError(line_nb)
if strcmp(value, OBIStr_NA) == 0 :
if value == OBIStr_NA :
value_in_result = None
else :
value_in_result = bytes2str(value)

View File

@ -1,7 +1,8 @@
#cython: language_level=3
from libc.stdint cimport int32_t, int64_t
from libc.stdint cimport int32_t, int64_t, uint8_t
from posix.types cimport time_t
@ -47,8 +48,8 @@ cdef extern from "obitypes.h" nogil:
extern obibool_t OBIBool_NA
extern const_char_p OBISeq_NA
extern const_char_p OBIStr_NA
extern const_char_p OBIQual_int_NA
extern const_char_p OBIQual_char_NA
extern uint8_t* OBIQual_int_NA
const_char_p name_data_type(int data_type)