Files
ServerSync/lib/prompt_toolkit/eventloop/__pycache__/inputhook.cpython-314.pyc

64 lines
9.2 KiB
Plaintext
Raw Normal View History

2026-02-12 02:28:23 +02:00
+
9<><39>i<EFBFBD><00><01>a<00>0t$Rt^RIHt^RIt^RIt^RIt^RIt^RIt^RI t ^RIH
t
H t ^RIH t H t ^RIHtHtHtHt.ROt]'d^R IHt^R
IHt]t!R R4t]].R3,tR ]R&R RltRRlt!RR] 4tR#)a8
Similar to `PyOS_InputHook` of the Python API, we can plug in an input hook in
the asyncio event loop.
The way this works is by using a custom 'selector' that runs the other event
loop until the real selector is ready.
It's the responsibility of this event hook to return when there is input ready.
There are two ways to detect when input is ready:
The inputhook itself is a callable that receives an `InputHookContext`. This
callable should run the other event loop, and return when the main loop has
stuff to do. There are two ways to detect when to return:
- Call the `input_is_ready` method periodically. Quit when this returns `True`.
- Add the `fileno` as a watch to the external eventloop. Quit when file descriptor
becomes readable. (But don't read from it.)
Note that this is not the same as checking for `sys.stdin.fileno()`. The
eventloop of prompt-toolkit allows thread-based executors, for example for
asynchronous autocompletion. When the completion for instance is ready, we
also want prompt-toolkit to gain control again in order to display that.
)<01> annotationsN)<02>AbstractEventLoop<6F>get_running_loop)<02> BaseSelector<6F> SelectorKey)<04> TYPE_CHECKING<4E>Any<6E>Callable<6C>Mapping<6E>InputHookSelector<6F>InputHookContext<78> InputHook)<01>FileDescriptorLike)<01> TypeAliasc<01>2<00>]tRt^5tRtRRltRRltRtR#)r z(
Given as a parameter to the inputhook.
c<01>$<00>V^8<>dQhRRRRRR/#)<07><00>fileno<6E>int<6E>input_is_readyzCallable[[], bool]<5D>return<72>None<6E>)<01>formats"<22>I/tmp/pip-target-wqrk2shd/lib/python/prompt_toolkit/eventloop/inputhook.py<70> __annotate__<5F>InputHookContext.__annotate__:s"<00><00>-<2D>-<2D>s<EFBFBD>-<2D>4F<34>-<2D>4<EFBFBD>-<2D>c <09><00>WnW nR#<00>N<><02>_filenor)<03>selfrrs&&&r<00>__init__<5F>InputHookContext.__init__:s <00><00><1D> <0C>,<2C>rc<01><00>V^8<>dQhRR/#)rrrr)rs"rrr>s<00><00><1C><1C><03>rc <09><00>VP#r)r!<00>r"s&rr<00>InputHookContext.fileno>s <00><00><13>|<7C>|<7C>rr N)<08>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>__doc__r#r<00>__static_attributes__rrrr r 5s<00><00><08>-<2D><1C>rrc<01> <00>V^8<>dQhRRRR/#<00>r<00> inputhook<6F>"Callable[[InputHookContext], None]rrr)rs"rrrEs<00><00><10><10>1<><10><16>rc<05>p<00>\\P!4V4p\P!V4pV#)z3
Create a new event loop with the given inputhook.
)r <00> selectors<72>DefaultSelector<6F>asyncio<69>SelectorEventLoop)r1<00>selector<6F>loops& r<00>new_eventloop_with_inputhookr:Es.<00><00> !<21><19>!:<3A>!:<3A>!<<3C>i<EFBFBD>H<>H<EFBFBD> <12> $<24> $<24>X<EFBFBD> .<2E>D<EFBFBD> <0F>Krc<01> <00>V^8<>dQhRRRR/#r0r)rs"rrrPs<00><00>
<10>
<10>1<>
<10><16>
rc<05>H<00>\V4p\P!V4V#)zD
Create a new event loop with the given inputhook, and activate it.
)r:r6<00>set_event_loop)r1r9s& r<00>set_eventloop_with_inputhookr>Ps!<00><00> (<28> <09> 2<>D<EFBFBD> <0B><1A><1A>4<EFBFBD> <20> <0F>Krc<01>z<00>]tRt^]tRtRRltRRRlltRRltRR R
lltRR R llt R Rlt
RRlt Rt R#)r z<>
Usage:
selector = selectors.SelectSelector()
loop = asyncio.SelectorEventLoop(InputHookSelector(selector, inputhook))
asyncio.set_event_loop(loop)
c<01>$<00>V^8<>dQhRRRRRR/#)rr8rr1r2rrr)rs"rr<00>InputHookSelector.__annotate__fs$<00><00>%<25>%<25>$<24>%<25>1S<31>%<25> <0A>%rc <09>b<00>WnW n\P!4wVnVnR#r)r8r1<00>os<6F>pipe<70>_r<5F>_w)r"r8r1s&&&rr#<00>InputHookSelector.__init__fs"<00><00>!<21> <0A>"<22><0E><1D>7<EFBFBD>7<EFBFBD>9<EFBFBD><18><04><07><14>rNc<01>(<00>V^8<>dQhRRRRRRRR/#<00> r<00>fileobjr<00>events<74>
_EventMask<EFBFBD>datarrrr)rs"rrrAms2<00><00>B<01>B<01>)<29>B<01>3=<3D>B<01>EH<45>B<01> <14>Brc <09><<00>VPPWVR7#)<01>rM)r8<00>register<65>r"rJrKrMs&&&&rrP<00>InputHookSelector.registerms<00><00><14>}<7D>}<7D>%<25>%<25>g<EFBFBD>D<EFBFBD>%<25>A<>Arc<01> <00>V^8<>dQhRRRR/#)rrJrrrr)rs"rrrArs<00><00>1<>1<>"4<>1<><1B>1rc <09>8<00>VPPV4#r)r8<00>
unregister)r"rJs&&rrU<00>InputHookSelector.unregisterrs<00><00><13>}<7D>}<7D>'<27>'<27><07>0<>0rc<01>(<00>V^8<>dQhRRRRRRRR/#rIr)rs"rrrAus2<00><00>@<01>@<01>)<29>@<01>3=<3D>@<01>EH<45>@<01> <14>@rc <09><<00>VPPWRR7#)NrO)r8<00>modifyrQs&&&&rrY<00>InputHookSelector.modifyus<00><00><14>}<7D>}<7D>#<23>#<23>G<EFBFBD>$<24>#<23>?<3F>?rc<01> <00>V^8<>dQhRRRR/#)r<00>timeoutz float | Nonerz$list[tuple[SelectorKey, _EventMask]]r)rs"rrrAzs<00><00>7<16>7<16>#<23>7<16> -<2D>7rc <09>Zaaaa<06>\\\4R.44^8<>dSPP SR7#RoRoRVVVV3Rllp\
P !VR7pVP4RV3RllpSP\SPV44\PR 8wd%\P!SP...R4\P!SPR
4VP!4SfQhS# \dL%i;i) <0B>_ready<64>r\FNc<01><00>V^8<>dQhRR/#<00>rrrr)rs"rr<00>.InputHookSelector.select.<locals>.__annotate__<5F>s<00><00> <19> <19>d<EFBFBD> rc<01><><<04>SPPSR7o\P!SPR4RoR#)r_<00>xTN)r8<00>selectrC<00>writerF)<04>ready<64>resultr"r\s<00><><EFBFBD><EFBFBD>r<00> run_selector<6F>.InputHookSelector.select.<locals>.run_selector<6F>s1<00><><00><19>]<5D>]<5D>)<29>)<29>'<27>)<29>:<3A>F<EFBFBD> <0E>H<EFBFBD>H<EFBFBD>T<EFBFBD>W<EFBFBD>W<EFBFBD>d<EFBFBD> #<23><18>Er)<01>targetc<01><00>V^8<>dQhRR/#)rr<00>boolr)rs"rrrb<00>s<00><00> <19> <19><04> rc<01><<01>S#rr)rgs<00>rr<00>0InputHookSelector.select.<locals>.input_is_ready<64>s<00><><00><18>Lr<00>win32i)<11>len<65>getattrrr8re<00> threading<6E>Thread<61>startr1r rE<00>sys<79>platformrC<00>read<61>OSError<6F>join)r"r\ri<00>thrrgrhsff @@rre<00>InputHookSelector.selectzs<><00><><00>
<0F>w<EFBFBD>'<27>)<29>8<EFBFBD>R<EFBFBD>8<> 9<>A<EFBFBD> =<3D><17>=<3D>=<3D>'<27>'<27><07>'<27>8<> 8<><15><05><15><06> <19> <19> <17> <1D> <1D>\<5C> 2<><02>
<EFBFBD><08><08>
<EFBFBD> <19> <19> <0A><0E><0E>'<27><04><07><07><1E>@<40>A<> <11><13>|<7C>|<7C>w<EFBFBD>&<26><16> <0A> <0A>t<EFBFBD>w<EFBFBD>w<EFBFBD>i<EFBFBD><12>R<EFBFBD><14>6<> <0E>G<EFBFBD>G<EFBFBD>D<EFBFBD>G<EFBFBD>G<EFBFBD>T<EFBFBD> "<22> <0B><07><07> <09><15>!<21>!<21>!<21><15> <0A><><17> <11> <11>  <11>s<00>*AD<00> D*<03>)D*c<01><00>V^8<>dQhRR/#rar)rs"rrrA<00>s<00><00> <1E> <1E>t<EFBFBD> rc <0A><><00>VP'dA\P!VP4\P!VP4R;VnVnVPP4R#)z
Clean up resources.
N<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)rErC<00>closerFr8r's&rr<><00>InputHookSelector.close<73>sK<00><00> <10>7<EFBFBD>7<EFBFBD>7<EFBFBD> <0E>H<EFBFBD>H<EFBFBD>T<EFBFBD>W<EFBFBD>W<EFBFBD> <1D> <0E>H<EFBFBD>H<EFBFBD>T<EFBFBD>W<EFBFBD>W<EFBFBD> <1D><1E><1E><04><07>$<24>'<27> <0C> <0A> <0A><1B><1B>rc<01><00>V^8<>dQhRR/#)rrz(Mapping[FileDescriptorLike, SelectorKey]r)rs"rrrA<00>s<00><00>'<27>'<27>A<>'rc <09>6<00>VPP4#r)r8<00>get_mapr's&rr<><00>InputHookSelector.get_map<61>s<00><00><13>}<7D>}<7D>$<24>$<24>&<26>&r)rErFr1r8r) r)r*r+r,r-r#rPrUrYrer<>r<>r.rrrr r ]s2<00><00><08>%<25>B<01>
1<>@<01>
7<16>r <1E>'<27>'r)r:r>r r r ) <20>__conditional_annotations__r-<00>
__future__rr6rCrer4rvrsrrrr<00>typingrrr r
<00>__all__<5F> _typeshedr<00>typing_extensionsrrrLr r <00>__annotations__r:r>r )r<>s@r<00><module>r<>s<><00><><01><04>2#<23><0E> <09> <0A><10>
<EFBFBD><10>7<>/<2F>8<>8<> <02><07><11>,<2C>+<2B><14>J<EFBFBD>
<1C>
<1C> <20>!1<> 2<>D<EFBFBD> 8<>9<> <09>9<EFBFBD>9<><10>
<10>b'<27> <0C>b'r