def build_subpart(cfr_part, xml): subpart_title = get_subpart_group_title(xml) subpart = reg_text.build_subpart(subpart_title, cfr_part) sections = [] for ch in xml.xpath('./SECTION'): sections.extend(build_from_section(cfr_part, ch)) subpart.children = sections return subpart
def test_build_subparts_tree_reserver(self): text = u"Subpart C—[Reserved]" tree, _ = reg_text.build_subparts_tree( text, 8888, lambda p: reg_text.build_subpart(text, 8888)) self.assertEqual('', tree.text) self.assertEqual('subpart', tree.node_type) self.assertEqual(['8888', 'Subpart', 'C'], tree.label) self.assertEqual([], tree.children) self.assertEqual('[Reserved]', tree.title)
def build_subpart(reg_part, subpart_xml): subpart_title = get_subpart_title(subpart_xml) subpart = reg_text.build_subpart(subpart_title, reg_part) sections = [] for ch in subpart_xml.getchildren(): if ch.tag == 'SECTION': sections.extend(build_from_section(reg_part, ch)) subpart.children = sections return subpart