Files
ServerSync/lib/prompt_toolkit/__pycache__/validation.cpython-314.pyc

82 lines
11 KiB
Plaintext
Raw Normal View History

2026-02-12 02:28:23 +02:00
+
9<><39>i<EFBFBD><00><01><><00>Rt^RIHt^RIHtHt^RIHt^RIH t ^RI
H t ^RI H t Ht.ROt!R R]4t!RR ]R7t!RR]4t!RR
]4t!RR ]4t!RR]4t!RR ]4tR#)zV
Input validation for a `Buffer`.
(Validators will be called before accepting input.)
)<01> annotations)<02>ABCMeta<74>abstractmethod)<01>Callable<6C><01>run_in_executor_with_context)<01>Document)<02> FilterOrBool<6F> to_filter<65>ConditionalValidator<6F>ValidationError<6F> Validator<6F>ThreadedValidator<6F>DummyValidator<6F>DynamicValidatorc<01>Ba<00>]tRt^tRtRRV3RllltRRltRtV;t#)r z<>
Error raised by :meth:`.Validator.validate`.
:param cursor_position: The cursor position where the error occurred.
:param message: Text.
c<01>$<00>V^8<>dQhRRRRRR/#)<07><00>cursor_position<6F>int<6E>message<67>str<74>return<72>None<6E>)<01>formats"<22>@/tmp/pip-target-wqrk2shd/lib/python/prompt_toolkit/validation.py<70> __annotate__<5F>ValidationError.__annotate__"s!<00><00><1F><1F><03><1F>#<23><1F>t<EFBFBD><1F>c <09>><<01>\SV`V4WnW nR#<00>N)<04>super<65>__init__rr)<04>selfrr<00> __class__s&&&<26>rr#<00>ValidationError.__init__"s<00><><00> <0A><07><18><17>!<21>.<2E><1C><1E> rc<01><00>V^8<>dQhRR/#<00>rrrr)rs"rrr's<00><00>p<01>p<01>#<23>prc <09>l<00>VPP RVP: RVP: R2#)z(cursor_position=z
, message=<3D>))r%<00>__name__rr<00>r$s&r<00>__repr__<5F>ValidationError.__repr__'s8<00><00><16>.<2E>.<2E>)<29>)<29>*<2A>*;<3B>D<EFBFBD><P<><P<>;S<>S]<5D>^b<>^j<>^j<>]m<>mn<6D>o<>or<00>rr)<02><00>) r+<00>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>__doc__r#r-<00>__static_attributes__<5F> __classcell__)r%s@rr r s<00><><00><08><1F><1F>
p<01>prc<01>V<00>]tRt^+tRt]RRl4tRRlt]R
RRll4t Rt
R #) r az
Abstract base class for an input validator.
A validator is typically created in one of the following two ways:
- Either by overriding this class and implementing the `validate` method.
- Or by passing a callable to `Validator.from_callable`.
If the validation takes some time and needs to happen in a background
thread, this can be wrapped in a :class:`.ThreadedValidator`.
c<01> <00>V^8<>dQhRRRR/#<00>r<00>documentrrrr)rs"rr<00>Validator.__annotate__9s<00><00> <0A> <0A><18> <0A>d<EFBFBD> rc <0A><00>R#)z<>
Validate the input.
If invalid, this should raise a :class:`.ValidationError`.
:param document: :class:`~prompt_toolkit.document.Document` instance.
Nr<00>r$r;s&&r<00>validate<74>Validator.validate8s<00><00> rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrr<Bs<00><00> <12> <12>X<EFBFBD> <12>$<24> rc<00> <0A>R"<00>VPV4R# \dhi;i5i)z<>
Return a `Future` which is set when the validation is ready.
This function can be overloaded in order to provide an asynchronous
implementation.
N)r?r r>s&&r<00>validate_async<6E>Validator.validate_asyncBs'<00><00><00>  <12> <10>M<EFBFBD>M<EFBFBD>(<28> #<23><><1E> <12> <11> <12>s<00>'<01><00>'<01> $<03>'c<01>(<00>V^8<>dQhRRRRRRRR/#) r<00> validate_func<6E>Callable[[str], bool]<5D> error_messager<00>move_cursor_to_end<6E>boolrr r)rs"rrr<Ns8<00><00>X<01>X<01>,<2C>X<01><1B>X<01>!<21> X<01>
<13> Xrc <0A><00>\WV4#)a<>
Create a validator from a simple validate callable. E.g.:
.. code:: python
def is_valid(text):
return text in ['hello', 'world']
Validator.from_callable(is_valid, error_message='Invalid input')
:param validate_func: Callable that takes the input string, and returns
`True` if the input is valid input.
:param error_message: Message to be displayed if the input is invalid.
:param move_cursor_to_end: Move the cursor to the end of the input, if
the input is invalid.
)<01>_ValidatorFromCallable)<04>clsrFrHrIs&&&&r<00> from_callable<6C>Validator.from_callableMs<00><00>,&<26>m<EFBFBD>DV<44>W<>WrrN)z Invalid inputF) r+r2r3r4r5rr?rC<00> classmethodrNr6rrrr r +s6<00><00>
<08><14> <0A><14> <0A> <12><11>X<01><11>Xr)<01> metaclassc<01>><00>]tRt^ftRtRRltRRltRRltRtR #)
rLz(
Validate input from a simple callable.
c<01>(<00>V^8<>dQhRRRRRRRR/#) r<00>funcrGrHrrIrJrrr)rs"rr<00>#_ValidatorFromCallable.__annotate__ks,<00><00>5<>5<>)<29>5<>:=<3D>5<>SW<53>5<> <0A>5rc <09>*<00>WnW nW0nR#r!)rTrHrI)r$rTrHrIs&&&&rr#<00>_ValidatorFromCallable.__init__ks<00><00><19> <09>*<2A><1A>"4<>rc<01><00>V^8<>dQhRR/#r(r)rs"rrrUrs<00><00>9<>9<>#<23>9rc <09>$<00>RVP: R2#)zValidator.from_callable(r*)rTr,s&rr-<00>_ValidatorFromCallable.__repr__rs<00><00>)<29>$<24>)<29>)<29><1D>a<EFBFBD>8<>8rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrrUus<00><00>U<01>U<01><18>U<01>d<EFBFBD>Urc <09><><00>VPVP4'gAVP'd\VP4pM^p\ W P
R7hR#)r0r/N)rT<00>textrI<00>lenr rH)r$r;<00>indexs&& rr?<00>_ValidatorFromCallable.validateusJ<00><00><13>y<EFBFBD>y<EFBFBD><18><1D><1D>'<27>'<27><13>&<26>&<26>&<26><1B>H<EFBFBD>M<EFBFBD>M<EFBFBD>*<2A><05><19><05>!<21>%<25>AS<41>AS<41>T<> T<> (r)rHrTrIN) r+r2r3r4r5r#r-r?r6rrrrLrLfs<00><00><08>5<>9<>U<01>UrrLc<01>><00>]tRt^tRtRRltRRltRRltRtR #)
rz<>
Wrapper that runs input validation in a thread.
(Use this to prevent the user interface from becoming unresponsive if the
input validation takes too much time.)
c<01> <00>V^8<>dQhRRRR/#)r<00> validatorr rrr)rs"rr<00>ThreadedValidator.__annotate__<5F>s<00><00>#<23>#<23>)<29>#<23><04>#rc <09><00>WnR#r!<00>rc)r$rcs&&rr#<00>ThreadedValidator.__init__<5F>s<00><00>"<22>rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrrd<00>s<00><00>*<2A>*<2A><18>*<2A>d<EFBFBD>*rc <09><<00>VPPV4R#r!)rcr?r>s&&rr?<00>ThreadedValidator.validate<74>s<00><00> <0C><0E><0E><1F><1F><08>)rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrrd<00>s<00><00>B<01>B<01>X<EFBFBD>B<01>$<24>Brc<00> <0A>Paa"<00>RVV3Rllp\V4GRjx<01>L
R#L5i)z*
Run the `validate` function in a thread.
c<01><00>V^8<>dQhRR/#)rrrr)rs"rr<00>6ThreadedValidator.validate_async.<locals>.__annotate__<5F>s<00><00> +<2B> +<2B>t<EFBFBD> +rc<01>&<<02>SPS4#r!)r?)r;r$s<00><>r<00>run_validation_thread<61>?ThreadedValidator.validate_async.<locals>.run_validation_thread<61>s<00><><00><17>=<3D>=<3D><18>*<2A> *rNr)r$r;rpsff rrC<00> ThreadedValidator.validate_async<6E>s!<00><><00><00>
 +<2B> +<2B>+<2B>+@<40>A<>A<>A<>s <00>&<01>$<04>&rfN<> r+r2r3r4r5r#r?rCr6rrrrrs<00><00><08> #<23>*<2A>B<01>Brc<01>&<00>]tRt^<5E>tRtRRltRtR#)rz)
Validator class that accepts any input.
c<01> <00>V^8<>dQhRRRR/#r:r)rs"rr<00>DummyValidator.__annotate__<5F>s<00><00> <0A> <0A><18> <0A>d<EFBFBD> rc <09><00>R#r!rr>s&&rr?<00>DummyValidator.validate<74>s<00><00> rrN)r+r2r3r4r5r?r6rrrrr<00>s<00><00><08> <0A> rc<01>2<00>]tRt^<5E>tRtRRltRRltRtR#)r ze
Validator that can be switched on/off according to
a filter. (This wraps around another validator.)
c<01>$<00>V^8<>dQhRRRRRR/#)rrcr <00>filterr rrr)rs"rr<00>!ConditionalValidator.__annotate__<5F>s!<00><00>(<28>(<28>)<29>(<28>\<5C>(<28>d<EFBFBD>(rc <09>2<00>Wn\V4VnR#r!)rcr
r{)r$rcr{s&&&rr#<00>ConditionalValidator.__init__<5F>s<00><00>"<22><0E><1F><06>'<27><04> rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrr|<00>s<00><00>.<2E>.<2E><18>.<2E>d<EFBFBD>.rc <09>l<00>VP4'dVPPV4R#R#r!)r{rcr?r>s&&rr?<00>ConditionalValidator.validate<74>s$<00><00> <0F>;<3B>;<3B>=<3D>=<3D> <10>N<EFBFBD>N<EFBFBD> #<23> #<23>H<EFBFBD> -<2D> r)r{rcN)r+r2r3r4r5r#r?r6rrrr r <00>s<00><00><08>
(<28>.<2E>.rc<01>><00>]tRt^<5E>tRtRRltRRltRRltRtR #)
rz<>
Validator class that can dynamically returns any Validator.
:param get_validator: Callable that returns a :class:`.Validator` instance.
c<01> <00>V^8<>dQhRRRR/#)r<00> get_validatorzCallable[[], Validator | None]rrr)rs"rr<00>DynamicValidator.__annotate__<5F>s<00><00>+<2B>+<2B>&D<>+<2B><14>+rc <09><00>WnR#r!<00>r<>)r$r<>s&&rr#<00>DynamicValidator.__init__<5F>s<00><00>*<2A>rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrr<><00>s<00><00>%<25>%<25><18>%<25>d<EFBFBD>%rc <09>l<00>VP4;'g \4pVPV4R#r!)r<>rr?<00>r$r;rcs&& rr?<00>DynamicValidator.validate<74>s)<00><00><18>&<26>&<26>(<28><<3C><<3C>N<EFBFBD>,<<3C> <09><11><1A><1A>8<EFBFBD>$rc<01> <00>V^8<>dQhRRRR/#r:r)rs"rrr<><00>s<00><00>1<>1<>X<EFBFBD>1<>$<24>1rc<00> <09><>"<00>VP4;'g \4pVPV4GRjx<01>L
R#L5ir!)r<>rrCr<>s&& rrC<00>DynamicValidator.validate_async<6E>s2<00><00><00><18>&<26>&<26>(<28><<3C><<3C>N<EFBFBD>,<<3C> <09><17>&<26>&<26>x<EFBFBD>0<>0<>0<>s<00>7A<01>A<04>Ar<>Nrsrrrrr<00>s<00><00><08> +<2B>%<25>1<>1rN)r r r rrr)r5<00>
__future__r<00>abcrr<00>typingr<00>prompt_toolkit.eventlooprr;r<00>filtersr r
<00>__all__<5F> Exceptionr r rLrrr rrrr<00><module>r<>s<><00><01><04>
#<23>'<27><1B>A<><1E>,<2C> <02><07>p<01>i<EFBFBD>p<01>"8X<01>'<27>8X<01>vU<01>Y<EFBFBD>U<01>2B<01> <09>B<01>0 <0A>Y<EFBFBD> <0A> .<2E>9<EFBFBD> .<2E> 1<>y<EFBFBD>1r