Method: rich.console.Console.input
Calls: 16, Exceptions: 0, Paths: 3Back
Path 1: 14 calls (0.88)
Text (14)
True (14)
True (14)
False (14)
StringIO (14)
'foo\n' (4) 'NO\n' (3) 'y' (2) 'egg\n' (1) 'foo' (1) '' (1) '100' (1) 'n' (1)
1def input(
2 self,
3 prompt: TextType = "",
4 *,
5 markup: bool = True,
6 emoji: bool = True,
7 password: bool = False,
8 stream: Optional[TextIO] = None,
9 ) -> str:
10 """Displays a prompt and waits for input from the user. The prompt may contain color / style.
11
12 It works in the same way as Python's builtin :func:`input` function and provides elaborate line editing and history features if Python's builtin :mod:`readline` module is previously loaded.
13
14 Args:
15 prompt (Union[str, Text]): Text to render in the prompt.
16 markup (bool, optional): Enable console markup (requires a str prompt). Defaults to True.
17 emoji (bool, optional): Enable emoji (requires a str prompt). Defaults to True.
18 password: (bool, optional): Hide typed text. Defaults to False.
19 stream: (TextIO, optional): Optional file to read input from (rather than stdin). Defaults to None.
20
21 Returns:
22 str: Text read from stdin.
23 """
24 if prompt:
25 self.print(prompt, markup=markup, emoji=emoji, end="")
26 if password:
27 result = getpass("", stream=stream)
28 else:
29 if stream:
30 result = stream.readline()
31 else:
32 result = input()
33 return result
Path 2: 1 calls (0.06)
'foo:' (1)
True (1)
True (1)
False (1)
None (1)
'bar' (1)
1def input(
2 self,
3 prompt: TextType = "",
4 *,
5 markup: bool = True,
6 emoji: bool = True,
7 password: bool = False,
8 stream: Optional[TextIO] = None,
9 ) -> str:
10 """Displays a prompt and waits for input from the user. The prompt may contain color / style.
11
12 It works in the same way as Python's builtin :func:`input` function and provides elaborate line editing and history features if Python's builtin :mod:`readline` module is previously loaded.
13
14 Args:
15 prompt (Union[str, Text]): Text to render in the prompt.
16 markup (bool, optional): Enable console markup (requires a str prompt). Defaults to True.
17 emoji (bool, optional): Enable emoji (requires a str prompt). Defaults to True.
18 password: (bool, optional): Hide typed text. Defaults to False.
19 stream: (TextIO, optional): Optional file to read input from (rather than stdin). Defaults to None.
20
21 Returns:
22 str: Text read from stdin.
23 """
24 if prompt:
25 self.print(prompt, markup=markup, emoji=emoji, end="")
26 if password:
27 result = getpass("", stream=stream)
28 else:
29 if stream:
30 result = stream.readline()
31 else:
32 result = input()
33 return result
Path 3: 1 calls (0.06)
'foo:' (1)
True (1)
True (1)
True (1)
None (1)
'bar' (1)
1def input(
2 self,
3 prompt: TextType = "",
4 *,
5 markup: bool = True,
6 emoji: bool = True,
7 password: bool = False,
8 stream: Optional[TextIO] = None,
9 ) -> str:
10 """Displays a prompt and waits for input from the user. The prompt may contain color / style.
11
12 It works in the same way as Python's builtin :func:`input` function and provides elaborate line editing and history features if Python's builtin :mod:`readline` module is previously loaded.
13
14 Args:
15 prompt (Union[str, Text]): Text to render in the prompt.
16 markup (bool, optional): Enable console markup (requires a str prompt). Defaults to True.
17 emoji (bool, optional): Enable emoji (requires a str prompt). Defaults to True.
18 password: (bool, optional): Hide typed text. Defaults to False.
19 stream: (TextIO, optional): Optional file to read input from (rather than stdin). Defaults to None.
20
21 Returns:
22 str: Text read from stdin.
23 """
24 if prompt:
25 self.print(prompt, markup=markup, emoji=emoji, end="")
26 if password:
27 result = getpass("", stream=stream)
28 else:
29 if stream:
30 result = stream.readline()
31 else:
32 result = input()
33 return result