web/views/wdoc.py
changeset 6425 8d7c2fd2ac66
parent 6420 4c14be06e557
child 6459 7f46ec158c48
equal deleted inserted replaced
6423:c560f8d9faee 6425:8d7c2fd2ac66
    60         idx = node.getchildren().index(snode) + 1
    60         idx = node.getchildren().index(snode) + 1
    61     elif section.attrib.get('insertbefore'):
    61     elif section.attrib.get('insertbefore'):
    62         snode = index[section.attrib['insertbefore']]
    62         snode = index[section.attrib['insertbefore']]
    63         node = snode.parent
    63         node = snode.parent
    64         idx = node.getchildren().index(snode)
    64         idx = node.getchildren().index(snode)
    65     else:
    65     elif 'appendto' in section.attrib:
    66         node = index[section.attrib['appendto']]
    66         node = index[section.attrib['appendto']]
    67         idx = None
    67         idx = None
       
    68     else:
       
    69         node, idx = None, None
    68     return node, idx
    70     return node, idx
    69 
    71 
    70 def build_toc(config):
    72 def build_toc(config):
    71     alltocfiles = reversed(tuple(config.locate_all_files('toc.xml')))
    73     alltocfiles = reversed(tuple(config.locate_all_files('toc.xml')))
    72     maintoc = parse(alltocfiles.next()).getroot()
    74     maintoc = parse(alltocfiles.next()).getroot()
    77     # file
    79     # file
    78     for fpath in alltocfiles:
    80     for fpath in alltocfiles:
    79         toc = parse(fpath).getroot()
    81         toc = parse(fpath).getroot()
    80         for section in toc:
    82         for section in toc:
    81             node, idx = get_insertion_point(section, index)
    83             node, idx = get_insertion_point(section, index)
       
    84             if node is None:
       
    85                 continue
    82             if idx is None:
    86             if idx is None:
    83                 node.append(section)
    87                 node.append(section)
    84             else:
    88             else:
    85                 node.insert(idx, section)
    89                 node.insert(idx, section)
    86             section.parent = node
    90             section.parent = node