Method: rich.text.Text.align
Calls: 3, Exceptions: 0, Paths: 3Back
Path 1: 1 calls (0.33)
'left' (1)
10 (1)
' ' (1)
1def align(self, align: AlignMethod, width: int, character: str = " ") -> None:
2 """Align text to a given width.
3
4 Args:
5 align (AlignMethod): One of "left", "center", or "right".
6 width (int): Desired width.
7 character (str, optional): Character to pad with. Defaults to " ".
8 """
9 self.truncate(width)
10 excess_space = width - cell_len(self.plain)
11 if excess_space:
12 if align == "left":
13 self.pad_right(excess_space, character)
14 elif align == "center":
15 left = excess_space // 2
16 self.pad_left(left, character)
17 self.pad_right(excess_space - left, character)
18 else:
19 self.pad_left(excess_space, character)
Path 2: 1 calls (0.33)
'right' (1)
10 (1)
' ' (1)
1def align(self, align: AlignMethod, width: int, character: str = " ") -> None:
2 """Align text to a given width.
3
4 Args:
5 align (AlignMethod): One of "left", "center", or "right".
6 width (int): Desired width.
7 character (str, optional): Character to pad with. Defaults to " ".
8 """
9 self.truncate(width)
10 excess_space = width - cell_len(self.plain)
11 if excess_space:
12 if align == "left":
13 self.pad_right(excess_space, character)
14 elif align == "center":
15 left = excess_space // 2
16 self.pad_left(left, character)
17 self.pad_right(excess_space - left, character)
18 else:
19 self.pad_left(excess_space, character)
Path 3: 1 calls (0.33)
'center' (1)
10 (1)
' ' (1)
1def align(self, align: AlignMethod, width: int, character: str = " ") -> None:
2 """Align text to a given width.
3
4 Args:
5 align (AlignMethod): One of "left", "center", or "right".
6 width (int): Desired width.
7 character (str, optional): Character to pad with. Defaults to " ".
8 """
9 self.truncate(width)
10 excess_space = width - cell_len(self.plain)
11 if excess_space:
12 if align == "left":
13 self.pad_right(excess_space, character)
14 elif align == "center":
15 left = excess_space // 2
16 self.pad_left(left, character)
17 self.pad_right(excess_space - left, character)
18 else:
19 self.pad_left(excess_space, character)