Cython API: cleaner column rewriting API

This commit is contained in:
Celine Mercier
2019-03-13 11:13:55 +01:00
parent 6afd1294a7
commit b45c2ee653
3 changed files with 10 additions and 4 deletions

View File

@ -237,7 +237,8 @@ def run(config):
dcols[tag] = (view.rewrite_column_with_diff_attributes(old_column.name,
new_data_type=new_type,
new_nb_elements_per_line=new_nb_elements_per_line,
new_elements_names=new_elements_names),
new_elements_names=new_elements_names,
rewrite_last_line=False),
value_obitype)
# Update the dictionary:

View File

@ -32,7 +32,8 @@ cdef class View(OBIWrapper):
object column_name,
obitype_t new_data_type=*,
index_t new_nb_elements_per_line=*,
list new_elements_names=*)
list new_elements_names=*,
bint rewrite_last_line=*)
cpdef Line_selection new_selection(self,
list lines=*)

View File

@ -267,13 +267,17 @@ cdef class View(OBIWrapper) :
object column_name,
obitype_t new_data_type=<obitype_t>OBI_VOID,
index_t new_nb_elements_per_line=0,
list new_elements_names=None) :
list new_elements_names=None,
bint rewrite_last_line=False) :
cdef Column old_column
cdef Column new_column
cdef index_t length = len(self) - 1
cdef index_t length = len(self) # TODO because last line triggered error that triggered rewriting, but needs a cleaner way, or at least good documentation
cdef column_name_b = tobytes(column_name)
if rewrite_last_line is False:
length-=1
if not self.active() :
raise OBIDeactivatedInstanceError()