コード例 #1
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'])
コード例 #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
ファイル: toc.py プロジェクト: ielerol/regulations-site
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
ファイル: toc.py プロジェクト: jmcarp/regulations-site
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
ファイル: toc_applier.py プロジェクト: eregs/regulations-site
 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')