Last change on my branch

This commit is contained in:
2017-01-02 16:46:17 +01:00
parent 2139bfc748
commit 4a1d3167a7
3 changed files with 54 additions and 5 deletions

View File

@ -12,6 +12,8 @@ from ..capi.obiview cimport Alias_column_pair_p, \
from ..capi.obidmscolumn cimport OBIDMS_column_p
from .dms cimport __OBIDMS_VIEW_CLASS__
from obitools3.utils cimport tobytes, \
bytes2str
@ -102,10 +104,10 @@ cdef class View :
return view
def close(self):
if (self._pointer != NULL
and obi_save_and_close_view(self._pointer) < 0) :
raise Exception("Problem closing view %s" %
bytes2str(self.name))
if (self._pointer != NULL):
if obi_save_and_close_view(self._pointer) < 0 :
raise Exception("Problem closing view %s" %
bytes2str(self.name))
def __dealloc__(self):
self.close()
@ -238,7 +240,7 @@ cdef class View :
# view type property getter
@property
def type(self): # @ReservedAssignment
return bytes2str(self._pointer.infos.view_type)
return <bytes> self._pointer.infos.view_type
# comments property getter
@property
@ -410,3 +412,15 @@ cdef class Line :
# return view_infos_d
cdef register_view_class(bytes viewtype,
type classe):
"""
Each sub class of `dms.View` needs to be registered after its declaration
to declare its relationship with an `OBIType_t`
"""
global __OBIDMS_VIEW_CLASS__
assert issubclass(classe,View)
__OBIDMS_VIEW_CLASS__[viewtype]=classe