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'])
Exemplo n.º 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'])
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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')
Exemplo n.º 6
0
 def section(element, data):
     title_data = title_parsing.section(data)
     if title_data:
         element.update(title_data)
Exemplo n.º 7
0
 def section(element, data):
     title_data = title_parsing.section(data)
     if title_data:
         element.update(title_data)
Exemplo n.º 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')