Method: rich.bar.Bar.__rich_console__
Calls: 4, Exceptions: 0, Paths: 3Back
Path 1: 2 calls (0.5)
Console (2)
ConsoleOptions (2)
Segment (4)
None (2)
1def __rich_console__(
2 self, console: Console, options: ConsoleOptions
3 ) -> RenderResult:
4
5 width = min(
6 self.width if self.width is not None else options.max_width,
7 options.max_width,
8 )
9
10 if self.begin >= self.end:
11 yield Segment(" " * width, self.style)
12 yield Segment.line()
13 return
14
15 prefix_complete_eights = int(width * 8 * self.begin / self.size)
16 prefix_bar_count = prefix_complete_eights // 8
17 prefix_eights_count = prefix_complete_eights % 8
18
19 body_complete_eights = int(width * 8 * self.end / self.size)
20 body_bar_count = body_complete_eights // 8
21 body_eights_count = body_complete_eights % 8
22
23 # When start and end fall into the same cell, we ideally should render
24 # a symbol that's "center-aligned", but there is no good symbol in Unicode.
25 # In this case, we fall back to right-aligned block symbol for simplicity.
26
27 prefix = " " * prefix_bar_count
28 if prefix_eights_count:
29 prefix += BEGIN_BLOCK_ELEMENTS[prefix_eights_count]
30
31 body = FULL_BLOCK * body_bar_count
32 if body_eights_count:
33 body += END_BLOCK_ELEMENTS[body_eights_count]
34
35 suffix = " " * (width - len(body))
36
37 yield Segment(prefix + body[len(prefix) :] + suffix, self.style)
38 yield Segment.line()
Path 2: 1 calls (0.25)
Console (1)
ConsoleOptions (1)
Segment (2) None (1)
1def __rich_console__(
2 self, console: Console, options: ConsoleOptions
3 ) -> RenderResult:
4
5 width = min(
6 self.width if self.width is not None else options.max_width,
7 options.max_width,
8 )
9
10 if self.begin >= self.end:
11 yield Segment(" " * width, self.style)
12 yield Segment.line()
13 return
14
15 prefix_complete_eights = int(width * 8 * self.begin / self.size)
16 prefix_bar_count = prefix_complete_eights // 8
17 prefix_eights_count = prefix_complete_eights % 8
18
19 body_complete_eights = int(width * 8 * self.end / self.size)
20 body_bar_count = body_complete_eights // 8
21 body_eights_count = body_complete_eights % 8
22
23 # When start and end fall into the same cell, we ideally should render
24 # a symbol that's "center-aligned", but there is no good symbol in Unicode.
25 # In this case, we fall back to right-aligned block symbol for simplicity.
26
27 prefix = " " * prefix_bar_count
28 if prefix_eights_count:
29 prefix += BEGIN_BLOCK_ELEMENTS[prefix_eights_count]
30
31 body = FULL_BLOCK * body_bar_count
32 if body_eights_count:
33 body += END_BLOCK_ELEMENTS[body_eights_count]
34
35 suffix = " " * (width - len(body))
36
37 yield Segment(prefix + body[len(prefix) :] + suffix, self.style)
38 yield Segment.line()
Path 3: 1 calls (0.25)
Console (1)
ConsoleOptions (1)
Segment (2) None (1)
1def __rich_console__(
2 self, console: Console, options: ConsoleOptions
3 ) -> RenderResult:
4
5 width = min(
6 self.width if self.width is not None else options.max_width,
7 options.max_width,
8 )
9
10 if self.begin >= self.end:
11 yield Segment(" " * width, self.style)
12 yield Segment.line()
13 return
14
15 prefix_complete_eights = int(width * 8 * self.begin / self.size)
16 prefix_bar_count = prefix_complete_eights // 8
17 prefix_eights_count = prefix_complete_eights % 8
18
19 body_complete_eights = int(width * 8 * self.end / self.size)
20 body_bar_count = body_complete_eights // 8
21 body_eights_count = body_complete_eights % 8
22
23 # When start and end fall into the same cell, we ideally should render
24 # a symbol that's "center-aligned", but there is no good symbol in Unicode.
25 # In this case, we fall back to right-aligned block symbol for simplicity.
26
27 prefix = " " * prefix_bar_count
28 if prefix_eights_count:
29 prefix += BEGIN_BLOCK_ELEMENTS[prefix_eights_count]
30
31 body = FULL_BLOCK * body_bar_count
32 if body_eights_count:
33 body += END_BLOCK_ELEMENTS[body_eights_count]
34
35 suffix = " " * (width - len(body))
36
37 yield Segment(prefix + body[len(prefix) :] + suffix, self.style)
38 yield Segment.line()