Commit 392f110c authored by Celine Mercier's avatar Celine Mercier

new functions in the OBIDMS_column class to raise NotImplementedError

exceptions and to get the creation date of a column
parent 6ced3c48
......@@ -4,7 +4,9 @@ from .capi.obidms cimport OBIDMS_p
from .capi.obidmscolumn cimport OBIDMS_column_p
from .capi.obitypes cimport obiversion_t, OBIType_t
cdef class OBIDMS_column
cdef class OBIDMS:
......@@ -33,6 +35,10 @@ cdef class OBIDMS_column:
cdef str column_name
cpdef object get_item(self, size_t line_nb, str element_name)
# cpdef set_item(self, size_t line_nb, str element_name, object value) TODO
cpdef list get_elements_names(self)
cpdef str get_data_type(self)
cpdef size_t get_nb_lines_used(self)
cpdef str get_creation_date(self)
cpdef close(self)
......@@ -10,6 +10,8 @@ from .capi.obidmscolumn cimport obi_column_get_data_type_from_name, \
obi_column_get_line_count_from_name, \
obi_column_get_nb_lines_used, \
obi_column_get_elements_names, \
obi_column_get_formatted_creation_date, \
obi_column_get_formatted_creation_date_from_name, \
obi_create_column, \
obi_clone_column, \
obi_open_column, \
......@@ -63,12 +65,17 @@ cdef class OBIDMS :
cdef str column_name
cdef bytes column_name_b
cdef str data_type
cdef str creation_date
cdef obiversion_t latest_version
cdef size_t line_count
p = Path(self.dms_name+'.obidms')
print("{:<25} {:<25} {:<25} {:<25}".format('-Column name-','-Data type-','-Latest version number-', '-Line count of latest version-'))
print("{:<25} {:<25} {:<25} {:<25}".format('-Column name-',
'-Data type-',
'-Latest version number-',
'-Line count of latest version-'))
#'-Creation date of latest version-'))
for entry in p.iterdir():
if entry.suffix == ".obicol":
column_name = entry.stem
......@@ -77,13 +84,19 @@ cdef class OBIDMS :
data_type = bytes2str(name_data_type(obi_column_get_data_type_from_name(self.pointer, column_name_b)))
latest_version = obi_column_get_latest_version_from_name(self.pointer, column_name_b)
line_count = obi_column_get_line_count_from_name(self.pointer, column_name_b)
# creation_date = bytes2str(obi_column_get_formatted_creation_date_from_name(self.pointer, column_name_b)) #TODO
# print(creation_date)
dms[column_name]['data_type'] = data_type
dms[column_name]['latest_version'] = latest_version
dms[column_name]['line_count'] = line_count
# dms[column_name]['creation_date'] = creation_date
print("{:<25} {:<25} {:<25} {:<25}".format(column_name, data_type, latest_version, line_count))
return dms
cpdef OBIDMS_column open_column(self,
str column_name,
bint create=False,
......@@ -109,6 +122,9 @@ cdef class OBIDMS :
data_type = obi_column_get_data_type_from_name(self.pointer, column_name_b)
# Open the column with the right subclass depending on the data type and the mode (read-only or writable)
# TODO : check that data type is the same as previous version if it exists?
if data_type == 1 :
if (create or clone) :
column = OBIDMS_column_int_writable(self, column_name,
......@@ -266,18 +282,24 @@ cdef class OBIDMS_column :
cpdef object get_item(self, size_t line_nb, str element_name):
raise NotImplementedError
# cpdef set_item(self, size_t line_nb, str element_name, object value): TODO
# raise NotImplementedError
cpdef list get_elements_names(self):
cdef bytes elements_names
elements_names = obi_column_get_elements_names(self.pointer)
return (bytes2str(elements_names)).split(';')
cpdef str get_data_type(self):
return self.data_type
cpdef size_t get_nb_lines_used(self):
return obi_column_get_nb_lines_used(self.pointer)
cpdef str get_creation_date(self):
return bytes2str(obi_column_get_formatted_creation_date(self.pointer))
cpdef close(self):
raise NotImplementedError
......@@ -56,6 +56,11 @@ cdef extern from "obidmscolumn.h" nogil:
size_t obi_column_get_line_count_from_name(OBIDMS_p dms,
const_char_p column_name)
char* obi_column_get_formatted_creation_date(OBIDMS_column_p column)
char* obi_column_get_formatted_creation_date_from_name(OBIDMS_p dms,
const_char_p column_name)
cdef extern from "obidmscolumn_int.h" nogil:
int obi_column_set_obiint_with_elt_name(OBIDMS_column_p column,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment