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'])
示例#2
0
    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'])
示例#3
0
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
示例#4
0
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
示例#5
0
 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')
示例#6
0
 def section(element, data):
     title_data = title_parsing.section(data)
     if title_data:
         element.update(title_data)
示例#7
0
 def section(element, data):
     title_data = title_parsing.section(data)
     if title_data:
         element.update(title_data)
示例#8
0
 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')