qBFj(dZddlmZddlmZmZddlmZddlm Z ddl m Z ddl m Z mZgd ZGd d eZGd d eZGddeZGddeZGddeZGddeZGddeZdS)zV Input validation for a `Buffer`. (Validators will be called before accepting input.) ) annotations)ABCMetaabstractmethod)Callablerun_in_executor_with_context)Document) FilterOrBool to_filter)ConditionalValidatorValidationError ValidatorThreadedValidatorDummyValidatorDynamicValidatorc.eZdZdZd d fd Zdd ZxZS)rz Error raised by :meth:`.Validator.validate`. :param cursor_position: The cursor position where the error occurred. :param message: Text. rcursor_positionintmessagestrreturnNonecft|||_||_dSN)super__init__rr)selfrr __class__s GC:\PYTHON\_runtimes\venv\Lib\site-packages\prompt_toolkit/validation.pyrzValidationError.__init__"s. !!!. c@|jjd|jd|jdS)Nz(cursor_position=z , message=))r __name__rrrs r!__repr__zValidationError.__repr__'s-.)ooDr0r"r!rr+s     ^     -#( XXXX[XXXr"r) metaclassc*eZdZdZdd Zdd ZddZdS)r<z0 Validate input from a simple callable. funcr7r8rr9r:rrc0||_||_||_dSr)rCr8r9)rrCr8r9s r!rz_ValidatorFromCallable.__init__ks! *"4r"cd|jdS)NzValidator.from_callable(r$)rCr&s r!r'z_ValidatorFromCallable.__repr__rs8$)8888r"r.r c||js4|jrt|j}nd}t ||jdS)Nr)rr)rCtextr9lenrr8)rr.indexs r!r2z_ValidatorFromCallable.validateus\yy'' U& HM**!%ASTTT T  U Ur"N)rCr7r8rr9r:rrr(r?)r%r)r*r+rr'r2r0r"r!r<r<fs`55559999UUUUUUr"r<c*eZdZdZd dZd d Zd d Zd S)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.) validatorrrrc||_dSr)rK)rrKs r!rzThreadedValidator.__init__s "r"r.r c:|j|dSr)rKr2r1s r!r2zThreadedValidator.validates )))))r"cFKdfd }t|d{VdS)z: Run the `validate` function in a thread. rrc.Sr)r2)r.rsr!run_validation_threadz?ThreadedValidator.validate_async..run_validation_threads==** *r"N)rrr)rr.rPs`` r!r4z ThreadedValidator.validate_asyncsT  + + + + + + +++@AAAAAAAAAAAr"N)rKrrrr?r%r)r*r+rr2r4r0r"r!rrs` ####****BBBBBBr"rceZdZdZddZdS) rz1 Validator class that accepts any input. r.r rrcdSrr0r1s r!r2zDummyValidator.validates r"Nr?)r%r)r*r+r2r0r"r!rrs2      r"rc"eZdZdZd dZdd Zd S)r zq Validator that can be switched on/off according to a filter. (This wraps around another validator.) rKrfilterr rrc<||_t||_dSr)rKr rU)rrKrUs r!rzConditionalValidator.__init__s"'' r"r.r cf|r|j|dSdSr)rUrKr2r1s r!r2zConditionalValidator.validates8 ;;== . N # #H - - - - - . .r"N)rKrrUr rrr?)r%r)r*r+rr2r0r"r!r r sF ((((......r"r c*eZdZdZd dZd d Zd d Zd S)rz Validator class that can dynamically returns any Validator. :param get_validator: Callable that returns a :class:`.Validator` instance. get_validatorCallable[[], Validator | None]rrc||_dSr)rY)rrYs r!rzDynamicValidator.__init__s*r"r.r ct|p t}||dSr)rYrr2rr.rKs r!r2zDynamicValidator.validates8&&((rfs #"""""''''''''AAAAAA,,,,,,,,   pppppippp"8X8X8X8X8X'8X8X8X8XvUUUUUYUUU2BBBBB BBB0     Y    . . . . .9 . . . 11111y11111r"