コード例 #1
0
def split_to_segments(csv_text: str, yaml_doc):
    csv_rows = read_csv(csv_text)
    segment_definitions = InstructionSet(yaml_doc).by_segment
    for pdef in segment_definitions:
        start, end = pdef.select_applicable_boundaries(csv_rows)
        csv_segment = pop_rows(csv_rows, start, end)
        yield csv_segment, pdef
    yield csv_rows, InstructionSet(yaml_doc).default
コード例 #2
0
def test_pop_rows_remaining_rows_behaviour():
    rows = list(mock_rows())
    pop_rows(rows, "apt", "wed")
    assert rows[0] == ["wed more text", "1", "2"]
    assert rows[1] == ["zed some text"]
コード例 #3
0
def test_pop_rows_with_another_list_and_injection():
    assert pop_rows(List0, 'a', 'd') == List1[:3]
    assert List0 == List1[3:]
コード例 #4
0
def test_pop_rows():
    rows = list(mock_rows())
    a = pop_rows(rows, "bat", "dot")
    assert a == [["bat aa...ah", "1", "2"], ["can extra text", "1", "2"]]