Cython API: tobytes() function now handles None values
This commit is contained in:
@ -15,7 +15,10 @@ from obitools3.dms.capi.obierrno cimport OBI_LINE_IDX_ERROR, \
|
|||||||
OBI_ELT_IDX_ERROR
|
OBI_ELT_IDX_ERROR
|
||||||
#obi_errno
|
#obi_errno
|
||||||
|
|
||||||
|
#from obitools3.dms.obiseq cimport Nuc_Seq, Nuc_Seq_Stored
|
||||||
|
|
||||||
|
|
||||||
|
# TODO RollbackException?
|
||||||
cdef obi_errno_to_exception(int obi_errno, 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
|
global obi_errno
|
||||||
if obi_errno > 0 :
|
if obi_errno > 0 :
|
||||||
@ -60,6 +63,8 @@ cdef bytes tobytes(object string):
|
|||||||
@return a transcoded string
|
@return a transcoded string
|
||||||
@rtype: bytes
|
@rtype: bytes
|
||||||
"""
|
"""
|
||||||
|
if string is None:
|
||||||
|
return None
|
||||||
if isinstance(string, bytes):
|
if isinstance(string, bytes):
|
||||||
return string
|
return string
|
||||||
return str2bytes(string)
|
return str2bytes(string)
|
||||||
@ -98,7 +103,7 @@ cdef obitype_t get_obitype_single_value(object value) :
|
|||||||
elif value_type == bool :
|
elif value_type == bool :
|
||||||
value_obitype = OBI_BOOL
|
value_obitype = OBI_BOOL
|
||||||
elif value_type == str or value_type == bytes :
|
elif value_type == str or value_type == bytes :
|
||||||
if is_a_DNA_seq(tobytes(value)) :
|
if is_a_DNA_seq(tobytes(value)): #or value_type == Nuc_Seq or value_type == Nuc_Seq_Stored: # TODO discuss
|
||||||
value_obitype = OBI_SEQ
|
value_obitype = OBI_SEQ
|
||||||
elif len(value) == 1 :
|
elif len(value) == 1 :
|
||||||
value_obitype = OBI_CHAR
|
value_obitype = OBI_CHAR
|
||||||
|
Reference in New Issue
Block a user