Path 1: 908 calls (0.8)

Console (908)

60 (116) 80 (82) 3 (70) 100 (70) 88 (49) 8 (42) 96 (41) 1 (39) 15 (32) 4 (31)

'left' (368) 'default' (349) 'center' (104) 'right' (74) None (11) 'full' (2)

'fold' (549) 'ellipsis' (344) None (9) 'crop' (6)

8 (908)

False (897) None (11)

Lines (908)

1def wrap(
2        self,
3        console: "Console",
4        width: int,
5        *,
6        justify: Optional["JustifyMethod"] = None,
7        overflow: Optional["OverflowMethod"] = None,
8        tab_size: int = 8,
9        no_wrap: Optional[bool] = None,
10    ) -> Lines:
11        """Word wrap the text.
12
13        Args:
14            console (Console): Console instance.
15            width (int): Number of characters per line.
16            emoji (bool, optional): Also render emoji code. Defaults to True.
17            justify (str, optional): Justify method: "default", "left", "center", "full", "right". Defaults to "default".
18            overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
19            tab_size (int, optional): Default tab size. Defaults to 8.
20            no_wrap (bool, optional): Disable wrapping, Defaults to False.
21
22        Returns:
23            Lines: Number of lines.
24        """
25        wrap_justify = justify or self.justify or DEFAULT_JUSTIFY
26        wrap_overflow = overflow or self.overflow or DEFAULT_OVERFLOW
27
28        no_wrap = pick_bool(no_wrap, self.no_wrap, False) or overflow == "ignore"
29
30        lines = Lines()
31        for line in self.split(allow_blank=True):
32            if "\t" in line:
33                line.expand_tabs(tab_size)
34            if no_wrap:
35                new_lines = Lines([line])
36            else:
37                offsets = divide_line(str(line), width, fold=wrap_overflow == "fold")
38                new_lines = line.divide(offsets)
39            for line in new_lines:
40                line.rstrip_end(width)
41            if wrap_justify:
42                new_lines.justify(
43                    console, width, justify=wrap_justify, overflow=wrap_overflow
44                )
45            for line in new_lines:
46                line.truncate(width, overflow=wrap_overflow)
47            lines.extend(new_lines)
48        return lines
            

Path 2: 221 calls (0.2)

Console (221)

4 (41) 20 (40) 12 (14) 80 (14) 96 (13) 46 (12) 6 (9) 14 (7) 7 (7) 19 (7)

'left' (126) 'default' (61) 'center' (19) 'right' (15)

'ellipsis' (151) 'fold' (48) 'ignore' (21) 'crop' (1)

8 (221)

True (211) False (10)

Lines (221)

1def wrap(
2        self,
3        console: "Console",
4        width: int,
5        *,
6        justify: Optional["JustifyMethod"] = None,
7        overflow: Optional["OverflowMethod"] = None,
8        tab_size: int = 8,
9        no_wrap: Optional[bool] = None,
10    ) -> Lines:
11        """Word wrap the text.
12
13        Args:
14            console (Console): Console instance.
15            width (int): Number of characters per line.
16            emoji (bool, optional): Also render emoji code. Defaults to True.
17            justify (str, optional): Justify method: "default", "left", "center", "full", "right". Defaults to "default".
18            overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
19            tab_size (int, optional): Default tab size. Defaults to 8.
20            no_wrap (bool, optional): Disable wrapping, Defaults to False.
21
22        Returns:
23            Lines: Number of lines.
24        """
25        wrap_justify = justify or self.justify or DEFAULT_JUSTIFY
26        wrap_overflow = overflow or self.overflow or DEFAULT_OVERFLOW
27
28        no_wrap = pick_bool(no_wrap, self.no_wrap, False) or overflow == "ignore"
29
30        lines = Lines()
31        for line in self.split(allow_blank=True):
32            if "\t" in line:
33                line.expand_tabs(tab_size)
34            if no_wrap:
35                new_lines = Lines([line])
36            else:
37                offsets = divide_line(str(line), width, fold=wrap_overflow == "fold")
38                new_lines = line.divide(offsets)
39            for line in new_lines:
40                line.rstrip_end(width)
41            if wrap_justify:
42                new_lines.justify(
43                    console, width, justify=wrap_justify, overflow=wrap_overflow
44                )
45            for line in new_lines:
46                line.truncate(width, overflow=wrap_overflow)
47            lines.extend(new_lines)
48        return lines
            

Path 3: 1 calls (0.0)

Console (1)

4 (1)

None (1)

None (1)

8 (1)

None (1)

Lines (1)

1def wrap(
2        self,
3        console: "Console",
4        width: int,
5        *,
6        justify: Optional["JustifyMethod"] = None,
7        overflow: Optional["OverflowMethod"] = None,
8        tab_size: int = 8,
9        no_wrap: Optional[bool] = None,
10    ) -> Lines:
11        """Word wrap the text.
12
13        Args:
14            console (Console): Console instance.
15            width (int): Number of characters per line.
16            emoji (bool, optional): Also render emoji code. Defaults to True.
17            justify (str, optional): Justify method: "default", "left", "center", "full", "right". Defaults to "default".
18            overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None.
19            tab_size (int, optional): Default tab size. Defaults to 8.
20            no_wrap (bool, optional): Disable wrapping, Defaults to False.
21
22        Returns:
23            Lines: Number of lines.
24        """
25        wrap_justify = justify or self.justify or DEFAULT_JUSTIFY
26        wrap_overflow = overflow or self.overflow or DEFAULT_OVERFLOW
27
28        no_wrap = pick_bool(no_wrap, self.no_wrap, False) or overflow == "ignore"
29
30        lines = Lines()
31        for line in self.split(allow_blank=True):
32            if "\t" in line:
33                line.expand_tabs(tab_size)
34            if no_wrap:
35                new_lines = Lines([line])
36            else:
37                offsets = divide_line(str(line), width, fold=wrap_overflow == "fold")
38                new_lines = line.divide(offsets)
39            for line in new_lines:
40                line.rstrip_end(width)
41            if wrap_justify:
42                new_lines.justify(
43                    console, width, justify=wrap_justify, overflow=wrap_overflow
44                )
45            for line in new_lines:
46                line.truncate(width, overflow=wrap_overflow)
47            lines.extend(new_lines)
48        return lines