aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.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/base.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/base.py')
-rw-r--r--contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py274
1 files changed, 137 insertions, 137 deletions
diff --git a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py
index e72f03a1e4..9885a37bc2 100644
--- a/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py
+++ b/contrib/python/prompt-toolkit/py3/prompt_toolkit/input/base.py
@@ -1,131 +1,131 @@
-"""
-Abstraction of CLI Input.
-"""
-from abc import ABCMeta, abstractmethod, abstractproperty
-from contextlib import contextmanager
-from typing import Callable, ContextManager, Generator, List
-
-from prompt_toolkit.key_binding import KeyPress
-
-__all__ = [
- "Input",
- "DummyInput",
-]
-
-
-class Input(metaclass=ABCMeta):
- """
- Abstraction for any input.
-
- An instance of this class can be given to the constructor of a
- :class:`~prompt_toolkit.application.Application` and will also be
- passed to the :class:`~prompt_toolkit.eventloop.base.EventLoop`.
- """
-
- @abstractmethod
- def fileno(self) -> int:
- """
- Fileno for putting this in an event loop.
- """
-
- @abstractmethod
- def typeahead_hash(self) -> str:
- """
- Identifier for storing type ahead key presses.
- """
-
- @abstractmethod
- def read_keys(self) -> List[KeyPress]:
- """
- Return a list of Key objects which are read/parsed from the input.
- """
-
- def flush_keys(self) -> List[KeyPress]:
- """
- Flush the underlying parser. and return the pending keys.
- (Used for vt100 input.)
- """
- return []
-
- def flush(self) -> None:
- "The event loop can call this when the input has to be flushed."
- pass
-
- @abstractproperty
- def closed(self) -> bool:
- "Should be true when the input stream is closed."
- return False
-
- @abstractmethod
- def raw_mode(self) -> ContextManager[None]:
- """
- Context manager that turns the input into raw mode.
- """
-
- @abstractmethod
- def cooked_mode(self) -> ContextManager[None]:
- """
- Context manager that turns the input into cooked mode.
- """
-
- @abstractmethod
- def attach(self, input_ready_callback: Callable[[], None]) -> ContextManager[None]:
- """
- Return a context manager that makes this input active in the current
- event loop.
- """
-
- @abstractmethod
- def detach(self) -> ContextManager[None]:
- """
- Return a context manager that makes sure that this input is not active
- in the current event loop.
- """
-
- def close(self) -> None:
- "Close input."
- pass
-
-
-class PipeInput(Input):
- """
- Abstraction for pipe input.
- """
-
- @abstractmethod
- def send_bytes(self, data: bytes) -> None:
- """Feed byte string into the pipe"""
-
- @abstractmethod
- def send_text(self, data: str) -> None:
- """Feed a text string into the pipe"""
-
-
-class DummyInput(Input):
- """
- Input for use in a `DummyApplication`
- """
-
- def fileno(self) -> int:
- raise NotImplementedError
-
- def typeahead_hash(self) -> str:
- return "dummy-%s" % id(self)
-
- def read_keys(self) -> List[KeyPress]:
- return []
-
- @property
- def closed(self) -> bool:
- return True
-
- def raw_mode(self) -> ContextManager[None]:
- return _dummy_context_manager()
-
- def cooked_mode(self) -> ContextManager[None]:
- return _dummy_context_manager()
-
- def attach(self, input_ready_callback: Callable[[], None]) -> ContextManager[None]:
+"""
+Abstraction of CLI Input.
+"""
+from abc import ABCMeta, abstractmethod, abstractproperty
+from contextlib import contextmanager
+from typing import Callable, ContextManager, Generator, List
+
+from prompt_toolkit.key_binding import KeyPress
+
+__all__ = [
+ "Input",
+ "DummyInput",
+]
+
+
+class Input(metaclass=ABCMeta):
+ """
+ Abstraction for any input.
+
+ An instance of this class can be given to the constructor of a
+ :class:`~prompt_toolkit.application.Application` and will also be
+ passed to the :class:`~prompt_toolkit.eventloop.base.EventLoop`.
+ """
+
+ @abstractmethod
+ def fileno(self) -> int:
+ """
+ Fileno for putting this in an event loop.
+ """
+
+ @abstractmethod
+ def typeahead_hash(self) -> str:
+ """
+ Identifier for storing type ahead key presses.
+ """
+
+ @abstractmethod
+ def read_keys(self) -> List[KeyPress]:
+ """
+ Return a list of Key objects which are read/parsed from the input.
+ """
+
+ def flush_keys(self) -> List[KeyPress]:
+ """
+ Flush the underlying parser. and return the pending keys.
+ (Used for vt100 input.)
+ """
+ return []
+
+ def flush(self) -> None:
+ "The event loop can call this when the input has to be flushed."
+ pass
+
+ @abstractproperty
+ def closed(self) -> bool:
+ "Should be true when the input stream is closed."
+ return False
+
+ @abstractmethod
+ def raw_mode(self) -> ContextManager[None]:
+ """
+ Context manager that turns the input into raw mode.
+ """
+
+ @abstractmethod
+ def cooked_mode(self) -> ContextManager[None]:
+ """
+ Context manager that turns the input into cooked mode.
+ """
+
+ @abstractmethod
+ def attach(self, input_ready_callback: Callable[[], None]) -> ContextManager[None]:
+ """
+ Return a context manager that makes this input active in the current
+ event loop.
+ """
+
+ @abstractmethod
+ def detach(self) -> ContextManager[None]:
+ """
+ Return a context manager that makes sure that this input is not active
+ in the current event loop.
+ """
+
+ def close(self) -> None:
+ "Close input."
+ pass
+
+
+class PipeInput(Input):
+ """
+ Abstraction for pipe input.
+ """
+
+ @abstractmethod
+ def send_bytes(self, data: bytes) -> None:
+ """Feed byte string into the pipe"""
+
+ @abstractmethod
+ def send_text(self, data: str) -> None:
+ """Feed a text string into the pipe"""
+
+
+class DummyInput(Input):
+ """
+ Input for use in a `DummyApplication`
+ """
+
+ def fileno(self) -> int:
+ raise NotImplementedError
+
+ def typeahead_hash(self) -> str:
+ return "dummy-%s" % id(self)
+
+ def read_keys(self) -> List[KeyPress]:
+ return []
+
+ @property
+ def closed(self) -> bool:
+ return True
+
+ def raw_mode(self) -> ContextManager[None]:
+ return _dummy_context_manager()
+
+ def cooked_mode(self) -> ContextManager[None]:
+ return _dummy_context_manager()
+
+ def attach(self, input_ready_callback: Callable[[], None]) -> ContextManager[None]:
# Call the callback immediately once after attaching.
# This tells the callback to call `read_keys` and check the
# `input.closed` flag, after which it won't receive any keys, but knows
@@ -133,12 +133,12 @@ class DummyInput(Input):
# `application.py`.
input_ready_callback()
- return _dummy_context_manager()
-
- def detach(self) -> ContextManager[None]:
- return _dummy_context_manager()
-
-
-@contextmanager
-def _dummy_context_manager() -> Generator[None, None, None]:
- yield
+ return _dummy_context_manager()
+
+ def detach(self) -> ContextManager[None]:
+ return _dummy_context_manager()
+
+
+@contextmanager
+def _dummy_context_manager() -> Generator[None, None, None]:
+ yield