Example #1
0
def toc_interp(data, so_far, toc):
    """Transforms a subpart, expanding it into subterps (collections of
    interpreted subparts, empty part, and appendices"""
    segments = title_parsing.try_split(data['title'])
    if not segments:
        segments = 'Supplement I', ''
    element = {
        'label': segments[0],
        'sub_label': segments[1],
        'index': data['index'],
        'section_id': '-'.join(data['index']),
        'is_supplement': True,
        'sub_toc': []
    }

    reg_part = data['index'][0]
    element['sub_toc'].extend(intro_interps(toc, reg_part))
    element['sub_toc'].extend(subterps(so_far, reg_part))
    return element
Example #2
0
def toc_interp(data, so_far, toc):
    """Transforms a subpart, expanding it into subterps (collections of
    interpreted subparts, empty part, and appendices"""
    segments = title_parsing.try_split(data['title'])
    if not segments:
        segments = 'Supplement I', ''
    element = {
        'label': segments[0],
        'sub_label': segments[1],
        'index': data['index'],
        'section_id': '-'.join(data['index']),
        'is_supplement': True,
        'sub_toc': []
    }

    reg_part = data['index'][0]
    element['sub_toc'].extend(intro_interps(toc, reg_part))
    element['sub_toc'].extend(subterps(so_far, reg_part))
    return element
Example #3
0
 def test_try_split(self):
     self.assertEqual(['a', 'xb'],
                      title_parsing.try_split('a:xb', ('|', ':', 'x')))
 def test_try_split(self):
     self.assertEqual(
         ['a', 'xb'],
         title_parsing.try_split('a:xb', ('|', ':', 'x')))