Method: rich.cells.chop_cells
Calls: 20, Exceptions: 0, Paths: 1Back
Path 1: 20 calls (1.0)
'test_can_handle_special_characters_in_docstrings.
6 (6) 46 (5) 4 (4) 7 (1) 3 (1) 10 (1) 100 (1) 76 (1)
0 (20)
[':)(gnihtemoS.>slacol<.sgnirtscod_ni_sretcarahc', '_laiceps_eldnah_nac_tset'] (5) ['(tuoya', 'L'] (3) ["'oof'=", 'eman ', ' '] (2) ["'rab'=", 'eman...
1def chop_cells(text: str, max_size: int, position: int = 0) -> List[str]:
2 """Break text in to equal (cell) length strings, returning the characters in reverse
3 order"""
4 _get_character_cell_size = get_character_cell_size
5 characters = [
6 (character, _get_character_cell_size(character)) for character in text
7 ]
8 total_size = position
9 lines: List[List[str]] = [[]]
10 append = lines[-1].append
11
12 for character, size in reversed(characters):
13 if total_size + size > max_size:
14 lines.append([character])
15 append = lines[-1].append
16 total_size = size
17 else:
18 total_size += size
19 append(character)
20
21 return ["".join(line) for line in lines]