[library-web] [mallard] correctly create mallard cache for sections
- From: Frederic Peters <fpeters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [library-web] [mallard] correctly create mallard cache for sections
- Date: Wed, 6 Apr 2011 12:58:43 +0000 (UTC)
commit 66cfa9e43375f808c462113d2c4f1ecc4d7c7d1d
Author: Frédéric Péters <fpeters 0d be>
Date: Wed Apr 6 18:26:13 2011 +0530
[mallard] correctly create mallard cache for sections
src/modtypes/mallard.py | 18 +++++++++++++++++-
1 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/src/modtypes/mallard.py b/src/modtypes/mallard.py
index d296a05..f3d8907 100644
--- a/src/modtypes/mallard.py
+++ b/src/modtypes/mallard.py
@@ -48,9 +48,11 @@ class MallardPage:
link_title = None
sort_title = None
info_nodes = None
+ sections = None
def __init__(self, filename):
self.info_nodes = []
+ self.sections = []
tree = ET.parse(filename)
try:
@@ -68,7 +70,12 @@ class MallardPage:
if self.sort_title is None:
self.sort_title = dup_node(self.title_tag)
self.sort_title.attrib['type'] = 'sort'
- # XXX: support for section
+ for section in tree.findall('{%s}section' % MAL_NS):
+ title_tag = section.find('{%s}title' % MAL_NS)
+ self.sections.append({'id': section.attrib['id'],
+ 'title': dup_node(title_tag),
+ 'link_title': dup_node(title_tag),
+ 'sort_title': dup_node(title_tag)})
def page_info(self, element):
if element is None:
@@ -103,6 +110,15 @@ class MallardPage:
info.append(self.sort_title)
if self.title_tag:
e.append(dup_node(self.title_tag))
+ for section in self.sections:
+ section_node = ET.SubElement(e, '{%s}section' % MAL_NS)
+ section_node.attrib['id'] = '%s#%s' % (self.id, section.get('id'))
+ section_info = ET.SubElement(section_node, '{%s}info' % MAL_NS)
+ section.get('link_title').attrib['type'] = 'link'
+ section.get('sort_title').attrib['type'] = 'sort'
+ section_info.append(section.get('link_title'))
+ section_info.append(section.get('sort_title'))
+ section_node.append(section.get('title'))
return e
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]