aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py144
1 files changed, 72 insertions, 72 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py
index 61a798e869..de47c64933 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/posix_pipe.py
@@ -1,72 +1,72 @@
-import os
-from typing import ContextManager, TextIO, cast
-
-from ..utils import DummyContext
-from .base import PipeInput
-from .vt100 import Vt100Input
-
-__all__ = [
- "PosixPipeInput",
-]
-
-
-class PosixPipeInput(Vt100Input, PipeInput):
- """
- Input that is send through a pipe.
- This is useful if we want to send the input programmatically into the
- application. Mostly useful for unit testing.
-
- Usage::
-
- input = PosixPipeInput()
- input.send_text('inputdata')
- """
-
- _id = 0
-
- def __init__(self, text: str = "") -> None:
- self._r, self._w = os.pipe()
-
- class Stdin:
- encoding = "utf-8"
-
- def isatty(stdin) -> bool:
- return True
-
- def fileno(stdin) -> int:
- return self._r
-
- super().__init__(cast(TextIO, Stdin()))
- self.send_text(text)
-
- # Identifier for every PipeInput for the hash.
- self.__class__._id += 1
- self._id = self.__class__._id
-
- def send_bytes(self, data: bytes) -> None:
- os.write(self._w, data)
-
- def send_text(self, data: str) -> None:
- "Send text to the input."
- os.write(self._w, data.encode("utf-8"))
-
- def raw_mode(self) -> ContextManager[None]:
- return DummyContext()
-
- def cooked_mode(self) -> ContextManager[None]:
- return DummyContext()
-
- def close(self) -> None:
- "Close pipe fds."
- os.close(self._r)
- os.close(self._w)
-
- # We should assign `None` to 'self._r` and 'self._w',
- # The event loop still needs to know the the fileno for this input in order
- # to properly remove it from the selectors.
-
- def typeahead_hash(self) -> str:
- """
- This needs to be unique for every `PipeInput`.
- """
- return "pipe-input-%s" % (self._id,)
+import os
+from typing import ContextManager, TextIO, cast
+
+from ..utils import DummyContext
+from .base import PipeInput
+from .vt100 import Vt100Input
+
+__all__ = [
+ "PosixPipeInput",
+]
+
+
+class PosixPipeInput(Vt100Input, PipeInput):
+ """
+ Input that is send through a pipe.
+ This is useful if we want to send the input programmatically into the
+ application. Mostly useful for unit testing.
+
+ Usage::
+
+ input = PosixPipeInput()
+ input.send_text('inputdata')
+ """
+
+ _id = 0
+
+ def __init__(self, text: str = "") -> None:
+ self._r, self._w = os.pipe()
+
+ class Stdin:
+ encoding = "utf-8"
+
+ def isatty(stdin) -> bool:
+ return True
+
+ def fileno(stdin) -> int:
+ return self._r
+
+ super().__init__(cast(TextIO, Stdin()))
+ self.send_text(text)
+
+ # Identifier for every PipeInput for the hash.
+ self.__class__._id += 1
+ self._id = self.__class__._id
+
+ def send_bytes(self, data: bytes) -> None:
+ os.write(self._w, data)
+
+ def send_text(self, data: str) -> None:
+ "Send text to the input."
+ os.write(self._w, data.encode("utf-8"))
+
+ def raw_mode(self) -> ContextManager[None]:
+ return DummyContext()
+
+ def cooked_mode(self) -> ContextManager[None]:
+ return DummyContext()
+
+ def close(self) -> None:
+ "Close pipe fds."
+ os.close(self._r)
+ os.close(self._w)
+
+ # We should assign `None` to 'self._r` and 'self._w',
+ # The event loop still needs to know the the fileno for this input in order
+ # to properly remove it from the selectors.
+
+ def typeahead_hash(self) -> str:
+ """
+ This needs to be unique for every `PipeInput`.
+ """
+ return "pipe-input-%s" % (self._id,)