--- a/src/ldt/ldt/ldt_utils/models.py Fri Feb 03 11:50:52 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/models.py Fri Feb 03 12:09:54 2012 +0100
@@ -226,7 +226,7 @@
if not self.nb_annotation:
self.nb_annotation = 0
if not self.stat_annotation:
- self.stat_annotation = self.__list2str([0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + len(settings.SYNTAX.keys())))
+ self.__get_empty_stat()
super(Content, self).save(*args, **kwargs)
@@ -405,7 +405,7 @@
def __make_getter(self, i):
def inner_getter(self):
if not self.stat_annotation:
- self.stat_annotation = self.__list2str([0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + len(settings.SYNTAX.keys())))
+ self.__get_empty_stat()
l = self.__str2list(self.stat_annotation)
return l[Content.__pol_indices[i]]
return inner_getter
@@ -413,7 +413,7 @@
def __make_setter(self, i):
def inner_setter(self, value):
if not self.stat_annotation:
- self.stat_annotation = self.__list2str([0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + len(settings.SYNTAX.keys())))
+ self.__get_empty_stat()
l = self.__str2list(self.stat_annotation)
l[Content.__pol_indices[i]] = value
self.stat_annotation = self.__list2str(l)
@@ -431,14 +431,21 @@
def __str2list(self, s):
return [int(x) for x in s.split(',')]
+
+ def __get_empty_stat(self):
+ self.stat_annotation = self.__list2str([0] * (settings.DIVISIONS_FOR_STAT_ANNOTATION + len(settings.SYNTAX.keys())))
def annotation_volume(): #@NoSelf
def fget(self):
+ if not self.stat_annotation:
+ self.__get_empty_stat()
l = self.__str2list(self.stat_annotation)
return l[Content.__pol_indices['annotation_volume_begin']:Content.__pol_indices['annotation_volume_end']]
def fset(self, value): # value is a list
+ if not self.stat_annotation:
+ self.__get_empty_stat()
l = self.__str2list(self.stat_annotation)
l[Content.__pol_indices['annotation_volume_begin']:Content.__pol_indices['annotation_volume_end']] = value
self.stat_annotation = self.__list2str(l)
--- a/src/ldt/ldt/ldt_utils/stat.py Fri Feb 03 11:50:52 2012 +0100
+++ b/src/ldt/ldt/ldt_utils/stat.py Fri Feb 03 12:09:54 2012 +0100
@@ -52,13 +52,12 @@
return True
-
def add_annotation_to_stat(content, begin, end):
nb_division = settings.DIVISIONS_FOR_STAT_ANNOTATION
if not content.nb_annotation or not content.stat_annotation:
content.nb_annotation = 1
- content.stat_annotation = get_empty_stat_vector()
+ content.stat_annotation = get_empty_stat_field()
size_division = content.duration / nb_division
limits = [x * size_division for x in range(nb_division+1)]