75 media.set(u"src", content.iri_url(web_url)) |
76 media.set(u"src", content.iri_url(web_url)) |
76 media.set(u"video", videopath) |
77 media.set(u"video", videopath) |
77 media.set(u"pict", u"") |
78 media.set(u"pict", u"") |
78 media.set(u"extra", u"") |
79 media.set(u"extra", u"") |
79 |
80 |
80 if projects is None: |
81 if projects is None: |
81 projects = [] |
82 projects = [] |
82 annotations_nodes = {} |
83 annotations_nodes = {} |
83 for project in project: |
84 for project in project: |
84 ldtdoc = lxml.etree.fromstring(project.ldt.encode("utf-8")) |
85 ldtdoc = lxml.etree.fromstring(project.ldt.encode("utf-8")) |
85 res = ldtdoc.xpath("/iri/annotations/content") |
86 res = ldtdoc.xpath("/iri/annotations/content") |
86 |
87 |
87 for content in res: |
88 for content in res: |
88 contentid = content.get("id") |
89 contentid = content.get("id") |
89 if annotations_nodes.has_key(contentid): |
90 if annotations_nodes.has_key(contentid): |
90 contentnode = annotations_nodes[contentid] |
91 contentnode = annotations_nodes[contentid] |
91 else: |
92 else: |
92 contentnode = {"id":contentid, "ensembles":[]} |
93 contentnode = {"id":contentid, "ensembles":[]} |
93 annotations_nodes[contentid] = contentnode |
94 annotations_nodes[contentid] = contentnode |
94 for ens in content.childNodes: |
95 for ens in content: |
95 if ens.tag.endswith("ensemble"): |
96 if ens.tag.endswith("ensemble"): |
96 contentnode["ensembles"].append(ens.tag) |
97 contentnode["ensembles"].append(deepcopy(ens)) |
97 |
98 |
98 annotations = lxml.etree.SubElement(iri, "annotations") |
99 annotations = lxml.etree.SubElement(iri, "annotations") |
99 if len(annotations_nodes) > 0: |
100 if len(annotations_nodes) > 0: |
100 for content in contentList: |
101 for content in contentList: |
101 if content.content_base.iri_id in annotations_nodes: |
102 if content.iri_id in annotations_nodes: |
102 contentnode = annotations_nodes[content.content_base.iri_id] |
103 contentnode = annotations_nodes[content.content_base.iri_id] |
103 if contentnode is not None: |
104 if contentnode is not None: |
104 if len(contentnode["ensembles"]) > 0: |
105 if len(contentnode["ensembles"]) > 0: |
105 content = lxml.etree.SubElement(annotations, "content") |
106 content_node = lxml.etree.SubElement(annotations, "content") |
106 content.set("id", contentnode["id"]) |
107 content_node.set("id", contentnode["id"]) |
107 content.text = u"" |
108 content_node.text = u"" |
108 else: |
109 for ens in contentnode["ensembles"]: |
109 content = lxml.etree.SubElement(annotations, "content") |
110 content_node.append(ens) |
110 content.set("id", contentnode["id"]) |
111 else: |
|
112 content_node = lxml.etree.SubElement(annotations, "content") |
|
113 content_node.set("id", contentnode["id"]) |
111 |
114 |
112 |
115 |
113 displays = lxml.etree.SubElement(iri, "displays") |
116 displays = lxml.etree.SubElement(iri, "displays") |
114 if len(contentList) > 0: |
117 if len(contentList) > 0: |
115 display = lxml.etree.SubElement(displays, "display") |
118 display = lxml.etree.SubElement(displays, "display") |