def test_section(self): elements = title_parsing.section({ 'index': ['204', '4'], 'title': '204.4 Sauce'}) self.assertTrue(elements['is_section']) self.assertEquals('Sauce', elements['sub_label']) elements = title_parsing.section({ 'index': ['204', '4'], 'title': '204.4 [Reserved]'}) self.assertTrue(elements['is_section']) self.assertEquals('[Reserved]', elements['sub_label'])
def test_section(self): elements = title_parsing.section({ 'index': ['204', '4'], 'title': '204.4 Sauce' }) self.assertTrue(elements['is_section']) self.assertEquals('Sauce', elements['sub_label']) elements = title_parsing.section({ 'index': ['204', '4'], 'title': '204.4 [Reserved]' }) self.assertTrue(elements['is_section']) self.assertEquals('[Reserved]', elements['sub_label'])
def toc_sect_appendix(data, so_far): """Transforms normal sections and appendices""" title_data = title_parsing.section(data) if title_data: data.update(title_data) title_data = title_parsing.appendix_supplement(data) if title_data: data.update(title_data) if 'label' not in data: data['label'] = data['title'] if data.get('is_appendix'): seen_appendix = any(el.get('is_appendix') for el in so_far) data['is_first_appendix'] = not seen_appendix return data
def test_section_with_leading_symbol_but_without_leading_section(self): elements = title_parsing.section({ 'index': ['204', '4'], 'title': '\xc2\xa7 Foo bar', }) self.assertEqual(elements['sub_label'], 'Foo bar')
def section(element, data): title_data = title_parsing.section(data) if title_data: element.update(title_data)