aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-06 18:18:01 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-04-06 18:18:01 +0300
commit01fbacb386809436dfa331780875aed72cb76118 (patch)
tree04c911ad96ff0523bd4d3e7a45c23cf2f2d7607d /contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py
parent48fb997d7f820a474b9094a72d9798a95ec612b7 (diff)
downloadydb-01fbacb386809436dfa331780875aed72cb76118.tar.gz
intermediate changes
ref:b4f892f3c2b06a356c155f73c27efc5661a7fb89
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py
index 347f8c6ad3..197dcb9a60 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/defaults.py
@@ -1,7 +1,5 @@
import sys
-from typing import Optional, TextIO
-
-from prompt_toolkit.utils import is_windows
+from typing import ContextManager, Optional, TextIO
from .base import DummyInput, Input, PipeInput
@@ -23,7 +21,7 @@ def create_input(
`sys.stdin`. (We can open `stdout` or `stderr` for reading, this is how
a `$PAGER` works.)
"""
- if is_windows():
+ if sys.platform == "win32":
from .win32 import Win32Input
# If `stdin` was assigned `None` (which happens with pythonw.exe), use
@@ -48,16 +46,24 @@ def create_input(
return Vt100Input(stdin)
-def create_pipe_input() -> PipeInput:
+def create_pipe_input() -> ContextManager[PipeInput]:
"""
Create an input pipe.
This is mostly useful for unit testing.
+
+ Usage::
+
+ with create_pipe_input() as input:
+ input.send_text('inputdata')
+
+ Breaking change: In prompt_toolkit 3.0.28 and earlier, this was returning
+ the `PipeInput` directly, rather than through a context manager.
"""
- if is_windows():
+ if sys.platform == "win32":
from .win32_pipe import Win32PipeInput
- return Win32PipeInput()
+ return Win32PipeInput.create()
else:
from .posix_pipe import PosixPipeInput
- return PosixPipeInput()
+ return PosixPipeInput.create()