aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py
diff options
context:
space:
mode:
authorIvan Blinkov <ivan@blinkov.ru>2022-02-10 16:47:11 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:47:11 +0300
commit5b283123c882433dafbaf6b338adeea16c1a0ea0 (patch)
tree339adc63bce23800021202ae4a8328a843dc447a /contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py
parent1aeb9a455974457866f78722ad98114bafc84e8a (diff)
downloadydb-5b283123c882433dafbaf6b338adeea16c1a0ea0.tar.gz
Restoring authorship annotation for Ivan Blinkov <ivan@blinkov.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py')
-rw-r--r--contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py126
1 files changed, 63 insertions, 63 deletions
diff --git a/contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py b/contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py
index f898796e06..0027873f88 100644
--- a/contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py
+++ b/contrib/python/prompt-toolkit/py2/prompt_toolkit/validation.py
@@ -1,64 +1,64 @@
-"""
-Input validation for a `Buffer`.
-(Validators will be called before accepting input.)
-"""
-from __future__ import unicode_literals
-from .filters import to_simple_filter
-
-from abc import ABCMeta, abstractmethod
-from six import with_metaclass
-
-__all__ = (
- 'ConditionalValidator',
- 'ValidationError',
- 'Validator',
-)
-
-
-class ValidationError(Exception):
- """
- Error raised by :meth:`.Validator.validate`.
-
- :param cursor_position: The cursor position where the error occured.
- :param message: Text.
- """
- def __init__(self, cursor_position=0, message=''):
- super(ValidationError, self).__init__(message)
- self.cursor_position = cursor_position
- self.message = message
-
- def __repr__(self):
- return '%s(cursor_position=%r, message=%r)' % (
- self.__class__.__name__, self.cursor_position, self.message)
-
-
-class Validator(with_metaclass(ABCMeta, object)):
- """
- Abstract base class for an input validator.
- """
- @abstractmethod
- def validate(self, document):
- """
- Validate the input.
- If invalid, this should raise a :class:`.ValidationError`.
-
- :param document: :class:`~prompt_toolkit.document.Document` instance.
- """
- pass
-
-
-class ConditionalValidator(Validator):
- """
- Validator that can be switched on/off according to
- a filter. (This wraps around another validator.)
- """
- def __init__(self, validator, filter):
- assert isinstance(validator, Validator)
-
- self.validator = validator
+"""
+Input validation for a `Buffer`.
+(Validators will be called before accepting input.)
+"""
+from __future__ import unicode_literals
+from .filters import to_simple_filter
+
+from abc import ABCMeta, abstractmethod
+from six import with_metaclass
+
+__all__ = (
+ 'ConditionalValidator',
+ 'ValidationError',
+ 'Validator',
+)
+
+
+class ValidationError(Exception):
+ """
+ Error raised by :meth:`.Validator.validate`.
+
+ :param cursor_position: The cursor position where the error occured.
+ :param message: Text.
+ """
+ def __init__(self, cursor_position=0, message=''):
+ super(ValidationError, self).__init__(message)
+ self.cursor_position = cursor_position
+ self.message = message
+
+ def __repr__(self):
+ return '%s(cursor_position=%r, message=%r)' % (
+ self.__class__.__name__, self.cursor_position, self.message)
+
+
+class Validator(with_metaclass(ABCMeta, object)):
+ """
+ Abstract base class for an input validator.
+ """
+ @abstractmethod
+ def validate(self, document):
+ """
+ Validate the input.
+ If invalid, this should raise a :class:`.ValidationError`.
+
+ :param document: :class:`~prompt_toolkit.document.Document` instance.
+ """
+ pass
+
+
+class ConditionalValidator(Validator):
+ """
+ Validator that can be switched on/off according to
+ a filter. (This wraps around another validator.)
+ """
+ def __init__(self, validator, filter):
+ assert isinstance(validator, Validator)
+
+ self.validator = validator
self.filter = to_simple_filter(filter)
-
- def validate(self, document):
- # Call the validator only if the filter is active.
- if self.filter():
- self.validator.validate(document)
+
+ def validate(self, document):
+ # Call the validator only if the filter is active.
+ if self.filter():
+ self.validator.validate(document)