MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / render_lines

Function render_lines

17-it-generator/tree/extra/drawtree.py:26–35  ·  view source on GitHub ↗
(tree_iter)

Source from the content-addressed store, hash-verified

24
25
26def render_lines(tree_iter):
27 cls, _, _ = next(tree_iter)
28 yield cls.__name__
29 prefix = ''
30
31 for cls, level, last in tree_iter:
32 prefix = prefix[:4 * (level - 1)]
33 prefix = prefix.replace(TEE, VLIN).replace(ELBOW, SP * 4)
34 prefix += ELBOW if last else TEE
35 yield prefix + cls.__name__
36
37
38def draw(cls):

Callers 8

test_1_levelFunction · 0.90
test_2_levels_1_leafFunction · 0.90
test_3_levels_1_leafFunction · 0.90
test_4_levels_1_leafFunction · 0.90
test_2_levels_2_leavesFunction · 0.90
drawFunction · 0.70

Calls 2

nextFunction · 0.85
replaceMethod · 0.45

Tested by 7

test_1_levelFunction · 0.72
test_2_levels_1_leafFunction · 0.72
test_3_levels_1_leafFunction · 0.72
test_4_levels_1_leafFunction · 0.72
test_2_levels_2_leavesFunction · 0.72