def _slice_text_lines(txt_lines: List[str], slices: Union[slice, List[slice]]) -> List[str]: "Extract lines based ob the slices given" if isinstance(slices, Iterable): line_groups = [txt_lines[sl] for sl in slices] txt_lines = sum(itz.interpose(['', '...', ''], line_groups), []) else: txt_lines = txt_lines[slices] return txt_lines
def interpose_commas(args): """Interpose commas args in between the given list of args. """ comma = { 'first_formatting': [], 'type': 'comma', 'second_formatting': [{ 'type': 'space', 'value': ' ' }] } res = interpose(comma, args) return list(res)
def test_interpose(): assert "a" == first(rest(interpose("a", range(1000000000)))) assert "tXaXrXzXaXn" == "".join(interpose("X", "tarzan")) assert list(interpose(0, itertools.repeat(1, 4))) == [1, 0, 1, 0, 1, 0, 1] assert list(interpose('.', ['a', 'b', 'c'])) == ['a', '.', 'b', '.', 'c']
def test_interpose(): l = list([1, 2, 3]) assert_that(pvector(interpose('foo', l))).is_equal_to(v(1, 'foo', 2, 'foo', 3)) assert_that(','.join(['foo', 'bar'])).is_equal_to('foo,bar')
def interpose_commas(args): """Interpose commas args in between the given list of args. """ comma = {'first_formatting': [], 'type': 'comma', 'second_formatting': [{'type': 'space', 'value': ' '}]} res = interpose(comma, args) return list(res)