Exemplo n.º 1
0
 def test_find_appendix_start(self):
     text = "Some \nAppendix C to Part 111 Other\n\n "
     text += "Thing Appendix A to Part 111"
     text += "\nAppendix B to Part 111"
     self.assertEqual(6, carving.find_appendix_start(text))
     self.assertEqual(59, carving.find_appendix_start(text[7:]))
     self.assertEqual(None, carving.find_appendix_start(text[7 + 60:]))
 def test_find_appendix_start(self):
     text = "Some \nAppendix C to Part 111 Other\n\n "
     text += "Thing Appendix A to Part 111"
     text += "\nAppendix B to Part 111"
     self.assertEqual(6, carving.find_appendix_start(text))
     self.assertEqual(59, carving.find_appendix_start(text[7:]))
     self.assertEqual(None, carving.find_appendix_start(text[7 + 60:]))
Exemplo n.º 3
0
def next_subpart_offsets(text):
    """Find the start,end of the next subpart"""
    offsets = find_offsets(text, find_next_subpart_start)
    if offsets is None:
        return None
    start, end = offsets
    appendix_start = find_appendix_start(text)
    supplement_start = find_supplement_start(text)
    if appendix_start is not None and appendix_start < end:
        return (start, appendix_start)
    if supplement_start is not None and supplement_start < end:
        return (start, supplement_start)
    return (start, end)
Exemplo n.º 4
0
def next_subpart_offsets(text):
    """Find the start,end of the next subpart"""
    offsets = find_offsets(text, find_next_subpart_start)
    if offsets is None:
        return None
    start, end = offsets
    appendix_start = find_appendix_start(text)
    supplement_start = find_supplement_start(text)
    if appendix_start is not None and appendix_start < end:
        end = appendix_start
    elif supplement_start is not None and supplement_start < end:
        end = supplement_start

    if end >= start:
        return (start, end)
Exemplo n.º 5
0
def next_section_offsets(text, part):
    """Find the start/end of the next section"""
    offsets = find_offsets(text, lambda t: find_next_section_start(t, part))
    if offsets is None:
        return None

    start, end = offsets
    subpart_start = find_next_subpart_start(text)
    appendix_start = find_appendix_start(text)
    supplement_start = find_supplement_start(text)
    if subpart_start is not None \
            and subpart_start > start and subpart_start < end:
        return (start, subpart_start)
    if appendix_start is not None and appendix_start < end:
        return (start, appendix_start)
    if supplement_start is not None and supplement_start < end:
        return (start, supplement_start)
    return (start, end)
Exemplo n.º 6
0
def next_section_offsets(text, part):
    """Find the start/end of the next section"""
    offsets = find_offsets(text, lambda t: find_next_section_start(t, part))
    if offsets is None:
        return None

    start, end = offsets
    subpart_start = find_next_subpart_start(text)
    appendix_start = find_appendix_start(text)
    supplement_start = find_supplement_start(text)
    if subpart_start is not None \
            and subpart_start > start and subpart_start < end:
        end = subpart_start
    elif appendix_start is not None and appendix_start < end:
        end = appendix_start
    elif supplement_start is not None and supplement_start < end:
        end = supplement_start

    if end >= start:
        return (start, end)