Cython API, Views: guessing an obitype from a python value is now done

through the corresponding functions in utils
This commit is contained in:
Celine Mercier
2019-03-07 13:57:37 +01:00
parent 4bc52c08c2
commit 2a1ab9db29

View File

@ -27,7 +27,8 @@ from obitools3.utils cimport tobytes, \
tostr, \
bytes2str_object, \
str2bytes_object, \
clean_empty_values_from_object
clean_empty_values_from_object, \
get_obitype
from ..object cimport OBIDeactivatedInstanceError
@ -262,6 +263,7 @@ cdef class View(OBIWrapper) :
# TODO warning, not multithreading compliant
# TODO there is a bug when rewriting a partial line with None values
cpdef Column rewrite_column_with_diff_attributes(self,
object column_name,
obitype_t new_data_type=<obitype_t>OBI_VOID,
@ -719,25 +721,8 @@ cdef class Line :
if value is None :
return # TODO discuss. This means that columns aren't created until an identifiable type is found
#raise RollbackException("Trying to create a column from a None value (can't guess type)", self)
value_type = type(value)
if value_type == int :
value_obitype = OBI_INT
elif value_type == float :
value_obitype = OBI_FLOAT
elif value_type == bool :
value_obitype = OBI_BOOL
elif value_type == str or value_type == bytes :
if value_type == str :
value_b = str2bytes(value)
else :
value_b = value
if is_a_DNA_seq(value_b) :
value_obitype = OBI_SEQ
elif len(value) == 1 :
value_obitype = OBI_CHAR
elif (len(value) > 1) :
value_obitype = OBI_STR
else :
value_obitype = get_obitype(value)
if value_obitype == OBI_VOID :
raise CantGuessTypeException(value)
#raise RollbackException("Could not guess the type of a value to create a new column", self._view)