diff -r b105636ae38d -r 7f2c2d9adf58 web/ldt/ldt_utils/models.py --- a/web/ldt/ldt_utils/models.py Tue Oct 12 19:12:27 2010 +0200 +++ b/web/ldt/ldt_utils/models.py Thu Oct 14 11:36:12 2010 +0200 @@ -298,56 +298,6 @@ else: return False - def getAnnotations(self, first_cutting=True): - doc = lxml.etree.fromstring(self.ldt) - - annotations = [] - - for contentnode in doc.xpath("/iri/annotations/content"): - iri_id = contentnode.get("id") - content = Content.objects.get(iri_id=iri_id) - - for cuttingnode in contentnode.xpath("ensemble/decoupage"): - - for annotationnode in cuttingnode.xpath("elements/element"): - tags = annotationnode.get('tags') - tags_list = [] - tags_list.extend(annotationnode.xpath("tags/tag/text()")) - if tags: - tags_list.append(tags) - - def accumulate(a, b): - a.extend(b) - return a - - tags_list = reduce(lambda a, s:accumulate(a,s.split(',')), tags_list, []) - - begin = annotationnode.get('begin') - if begin is None: - begin = 0 - else: - begin = int(begin) - - uri = None - if content.media_obj and content.media_obj.external_publication_url: - uri = "%s#t=%d" % (content.media_obj.external_publication_url, begin) - - annotations.append({ - 'begin': begin, - 'duration':annotationnode.get('dur'), - 'title':u"".join(annotationnode.xpath("title/text()")), - 'desc':u"".join(annotationnode.xpath("abstract/text()")), - 'tags': tags_list, - 'id':u"".join(annotationnode.get('id')), - 'uri':uri - }) - if first_cutting and len(annotations) > 0 : - break - if first_cutting and len(annotations) > 0 : - break - - return annotations - class Segment(models.Model):