Ejemplo n.º 1
0
 def test_make_sortable(self):
     """Verify that strings get decomposed correctly into sortable tuples"""
     self.assertEqual(utils.make_sortable("abc"), ("abc", ))
     self.assertEqual(utils.make_sortable("123"), (123, ))
     self.assertEqual(utils.make_sortable("abc123def456"),
                      ("abc", 123, "def", 456))
     self.assertEqual(utils.make_sortable("123abc456"), (123, "abc", 456))
 def test_make_sortable(self):
     """Verify that strings get decomposed correctly into sortable tuples"""
     self.assertEqual(utils.make_sortable("abc"), ("abc",))
     self.assertEqual(utils.make_sortable("123"), (123,))
     self.assertEqual(utils.make_sortable("abc123def456"),
                      ("abc", 123, "def", 456))
     self.assertEqual(utils.make_sortable("123abc456"), (123, "abc", 456))
Ejemplo n.º 3
0
def normalize_toc(toc_element):
    """Return a sorting order for a TOC element, primarily based on the
    index, and the type of content. General order is regulation text,
    appendices, then interpretations."""

    sortable_index = tuple(utils.make_sortable(l)
                           for l in toc_element['index'])
    if toc_element.get('is_section'):
        return (0,) + sortable_index
    elif toc_element.get('is_appendix'):
        return (1,) + sortable_index
    elif toc_element.get('is_supplement'):
        return (2,) + sortable_index
    else:
        return (3,) + sortable_index
Ejemplo n.º 4
0
def normalize_toc(toc_element):
    """Return a sorting order for a TOC element, primarily based on the
    index, and the type of content. General order is regulation text,
    appendices, then interpretations."""

    sortable_index = tuple(
        utils.make_sortable(l) for l in toc_element['index'])
    if toc_element.get('is_section'):
        return (0, ) + sortable_index
    elif toc_element.get('is_appendix'):
        return (1, ) + sortable_index
    elif toc_element.get('is_supplement'):
        return (2, ) + sortable_index
    else:
        return (3, ) + sortable_index