Cython API: Added a function to get a column from its index in the view
This commit is contained in:
@ -174,19 +174,21 @@ cdef class View(OBIWrapper) :
|
|||||||
|
|
||||||
|
|
||||||
def keys(self):
|
def keys(self):
|
||||||
cdef int i
|
|
||||||
cdef Obiview_p pointer = self.pointer()
|
cdef str col_alias
|
||||||
cdef int nb_column = pointer.infos.column_count
|
cdef int i
|
||||||
cdef Alias_column_pair_p column_p = pointer.infos.column_references
|
cdef Obiview_p pointer = self.pointer()
|
||||||
|
cdef int nb_column = pointer.infos.column_count
|
||||||
|
cdef Alias_column_pair_p column_p = pointer.infos.column_references
|
||||||
|
|
||||||
if not self.active() :
|
if not self.active() :
|
||||||
raise OBIObjectClosedInstance()
|
raise OBIObjectClosedInstance()
|
||||||
|
|
||||||
for i in range(nb_column) :
|
for i in range(nb_column) :
|
||||||
col_alias = bytes2str(pointer.infos.column_references[i].alias)
|
col_alias = bytes2str(column_p[i].alias)
|
||||||
yield col_alias
|
yield col_alias
|
||||||
|
|
||||||
|
|
||||||
def get_column(self,
|
def get_column(self,
|
||||||
object column_name):
|
object column_name):
|
||||||
|
|
||||||
@ -194,8 +196,23 @@ cdef class View(OBIWrapper) :
|
|||||||
raise OBIObjectClosedInstance()
|
raise OBIObjectClosedInstance()
|
||||||
|
|
||||||
return Column.open(self, column_name)
|
return Column.open(self, column_name)
|
||||||
|
|
||||||
|
|
||||||
|
def get_column_with_idx(self,
|
||||||
|
int column_idx):
|
||||||
|
|
||||||
|
cdef Obiview_p pointer = self.pointer()
|
||||||
|
cdef int nb_column = pointer.infos.column_count
|
||||||
|
|
||||||
|
if not self.active() :
|
||||||
|
raise OBIObjectClosedInstance()
|
||||||
|
|
||||||
|
if column_idx > nb_column :
|
||||||
|
raise IndexError(column_idx, "No column with this index")
|
||||||
|
|
||||||
|
return Column.open(self, pointer.infos.column_references[column_idx].alias)
|
||||||
|
|
||||||
|
|
||||||
cpdef delete_column(self,
|
cpdef delete_column(self,
|
||||||
object column_name) :
|
object column_name) :
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user