Merge branch 'dmitmel-master'

This commit is contained in:
Keanu Timmermans 2021-06-04 22:18:44 +02:00
commit 7bd91b677c
Signed by: keanucode
GPG key ID: A7431C0D513CA93B

View file

@ -13,7 +13,11 @@ def platform_not_supported_error() -> NoReturn:
raise Exception("platform '{}' is not supported!".format(sys.platform))
def run_chooser(choices: Iterable[str], prompt: Optional[str] = None, async_read: bool = False) -> int:
def run_chooser(
choices: Iterable[str],
prompt: Optional[str] = None,
async_read: bool = False,
) -> int:
supports_result_index = True
if os.isatty(sys.stderr.fileno()):
process_args = [
@ -41,7 +45,8 @@ def run_chooser(choices: Iterable[str], prompt: Optional[str] = None, async_read
with chooser_process.stdin as pipe:
for index, choice in enumerate(choices):
if "\n" not in choice:
if "\n" in choice:
raise Exception("choices can only span a single line")
if not supports_result_index:
pipe.write(str(index).encode())