equal
deleted
inserted
replaced
23 |
23 |
24 import io |
24 import io |
25 from itertools import chain |
25 from itertools import chain |
26 from os.path import join |
26 from os.path import join |
27 from xml.etree.ElementTree import parse |
27 from xml.etree.ElementTree import parse |
28 |
|
29 from six import text_type |
|
30 |
28 |
31 from logilab.common.registry import yes |
29 from logilab.common.registry import yes |
32 |
30 |
33 from cubicweb.predicates import match_form_params |
31 from cubicweb.predicates import match_form_params |
34 from cubicweb.view import StartupView |
32 from cubicweb.view import StartupView |
89 def title_for_lang(node, lang): |
87 def title_for_lang(node, lang): |
90 fallback_title = None |
88 fallback_title = None |
91 for title in node.findall('title'): |
89 for title in node.findall('title'): |
92 title_lang = title.attrib['{http://www.w3.org/XML/1998/namespace}lang'] |
90 title_lang = title.attrib['{http://www.w3.org/XML/1998/namespace}lang'] |
93 if title_lang == lang: |
91 if title_lang == lang: |
94 return text_type(title.text) |
92 return title.text |
95 if title_lang == 'en': |
93 if title_lang == 'en': |
96 fallback_title = text_type(title.text) |
94 fallback_title = title.text |
97 return fallback_title |
95 return fallback_title |
98 |
96 |
99 |
97 |
100 def subsections(node): |
98 def subsections(node): |
101 return [child for child in node if child.tag == 'section'] |
99 return [child for child in node if child.tag == 'section'] |