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

91 lines
16 KiB
Plaintext
Raw Normal View History

2026-02-12 02:28:23 +02:00
+
9<><39>i<EFBFBD>$<00><01><><00>Rt^RIHt^RIt^RIt^RIt^RIHtHt^RI H
t
^RI H t H t HtHt.ROt!R R]R 7t!R R]4t!RR
]4t!RR]4t]]]RR3,t!RR ]4tR#)aW
Implementations for the history of a `Buffer`.
NOTE: There is no `DynamicHistory`:
This doesn't work well, because the `Buffer` needs to be able to attach
an event handler to the event when a history entry is loaded. This
loading can be done asynchronously and making the history swappable would
probably break this.
)<01> annotationsN)<02>ABCMeta<74>abstractmethod)<01>get_running_loop)<04>AsyncGenerator<6F>Iterable<6C>Sequence<63>Union<6F>History<72>ThreadedHistory<72> DummyHistory<72> FileHistory<72>InMemoryHistoryc<01>v<00>]tRt^tRtRRltRRltRRltRR lt] R
R l4t
] R R l4t Rt R#)r
z[
Base ``History`` class.
This also includes abstract methods for loading/storing history.
c<01><00>V^8<>dQhRR/#<00><03><00>return<72>None<6E>)<01>formats"<22>=/tmp/pip-target-wqrk2shd/lib/python/prompt_toolkit/history.py<70> __annotate__<5F>History.__annotate__$s<00><00>-<2D>-<2D>$<24>-<2D>c <09>"<00>RVn.VnR#)FN<46><02>_loaded<65>_loaded_strings<67><01>selfs&r<00>__init__<5F>History.__init__$s<00><00><1C><04> <0C>+-<2D><04>rc<01><00>V^8<>dQhRR/#<00>rrzAsyncGenerator[str, None]r)rs"rrr0s<00><00><17><17>5<>rc <0A><>"<00>VP'g&\VP44VnRVnVPFpV5x<00>K
R#5i)a<>
Load the history and yield all the entries in reverse order (latest,
most recent history entry first).
This method can be called multiple times from the `Buffer` to
repopulate the history when prompting for a new input. So we are
responsible here for both caching, and making sure that strings that
were were appended to the history will be incorporated next time this
method is called.
TN)r<00>list<73>load_history_stringsr)r <00>items& r<00>load<61> History.load0sB<00><00><00><14>|<7C>|<7C>|<7C>#'<27><04>(A<>(A<>(C<>#D<>D<EFBFBD> <20><1F>D<EFBFBD>L<EFBFBD><18>(<28>(<28>D<EFBFBD><16>J<EFBFBD>)<29>s<00>AAc<01><00>V^8<>dQhRR/#)rrz list[str]r)rs"rrrBs<00><00>*<2A>*<2A>Y<EFBFBD>*rc <0A>.<00>VPRRR1,#)zY
Get the strings from the history that are loaded so far.
(In order. Oldest item first.)
N<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)rrs&r<00> get_strings<67>History.get_stringsBs<00><00>
<14>#<23>#<23>D<EFBFBD>b<EFBFBD>D<EFBFBD>)<29>)rc<01> <00>V^8<>dQhRRRR/#<00>r<00>string<6E>strrrr)rs"rrrI<00><00><00>"<22>"<22>C<EFBFBD>"<22>D<EFBFBD>"rc <0A>`<00>VPP^V4VPV4R#)zAdd string to the history.N)r<00>insert<72> store_string<6E>r r2s&&r<00> append_string<6E>History.append_stringIs&<00><00> <0C><1C><1C>#<23>#<23>A<EFBFBD>v<EFBFBD>.<2E> <0C><19><19>&<26>!rc<01><00>V^8<>dQhRR/#<00>rrz Iterable[str]r)rs"rrrSs<00><00> <12> <12>m<EFBFBD> rc# <0A>"<00>R#5i)z<>
This should be a generator that yields `str` instances.
It should yield the most recent items first, because they are the most
important. (The history can already be used, even when it's only
partially loaded.)
Nrrs&rr'<00>History.load_history_stringsRs
<00><00><00><14>s<00>c<01> <00>V^8<>dQhRRRR/#r1r)rs"rrr_s<00><00> <0C> <0C>3<EFBFBD> <0C>4<EFBFBD> rc <0A><00>R#)z)
Store the string in persistent storage.
Nrr8s&&rr7<00>History.store_string^s<00>rrN) <0A>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__firstlineno__<5F>__doc__r!r)r.r9rr'r7<00>__static_attributes__rrrr
r
sC<00><00><08> -<2D><17>$*<2A>"<22><14> <12><14> <12><14> <0C><14> r)<01> metaclassc<01>za<00>]tRt^etRtRV3RlltRRltRRltRR ltR
R lt R R lt
RRlt Rt V;t #)r a 
Wrapper around `History` implementations that run the `load()` generator in
a thread.
Use this to increase the start-up time of prompt_toolkit applications.
History entries are available as soon as they are loaded. We don't have to
wait for everything to be loaded.
c<01> <00>V^8<>dQhRRRR/#)r<00>historyr
rrr)rs"rr<00>ThreadedHistory.__annotate__os<00><00> =<3D> =<3D><07> =<3D>D<EFBFBD> =rc <09><><<01>\SV`4WnRVn\P
!4Vn.VnR#<00>N)<08>superr!rK<00> _load_thread<61> threading<6E>Lock<63>_lock<63>_string_load_events)r rK<00> __class__s&&<26>rr!<00>ThreadedHistory.__init__os5<00><><00> <0A><07><18><1A><1E> <0C>59<35><04><19><1F>^<5E>^<5E>%<25><04>
<EFBFBD>;=<3D><04> rc<01><00>V^8<>dQhRR/#r$r)rs"rrrL~s<00><00>73<>73<>5<>73rc <0A><>aaa"<00>SP'gB\P!SPRR7SnSPP 4\ 4p\P !4oSP4SPPS4^oVPRV3Rl4GRjx<01>L
pV'gK)RVVV3RllpVPRV4GRjx<01>L
wrES\V4, oVFpV5x<00>K
V'gKzSPPS4R#L}LP SPPS4i;i5i)zV
Like `History.load(), but call `self.load_history_strings()` in a
background thread.
T)<02>target<65>daemonNc<01>(<<01>SPRR7#)g<00>?)<01>timeout)<01>wait)<01>events<00>r<00><lambda><3E>&ThreadedHistory.load.<locals>.<lambda><3E>s<00><><00>%<25>*<2A>*<2A>S<EFBFBD>*<2A>"9rc<01><00>V^8<>dQhRR/#)rrztuple[list[str], bool]r)rs"rr<00>*ThreadedHistory.load.<locals>.__annotate__<5F>s<00><00>+<2B>+<2B>%;<3B>+rc<01><><<03>SP;_uu_4SPSRpSPpSP4RRR4W3# +'giXX3#;irN)rSrr<00>clear)<05> new_items<6D>doner^<00> items_yieldedr s <20><><EFBFBD>r<00> in_executor<6F>)ThreadedHistory.load.<locals>.in_executor<6F>sS<00><><00><1D><1A><1A><1A>$(<28>$8<>$8<><1D><1E>$H<> <09>#<23>|<7C>|<7C><04><1D> <0B> <0B> <0A>$<24>%<25>?<3F>*<2A> $<24><1A>%<25>d<EFBFBD>?<3F>*<2A>s <00>,A <05> A ) rPrQ<00>Thread<61>_in_load_thread<61>startr<00>Event<6E>setrT<00>append<6E>run_in_executor<6F>len<65>remove) r <00>loop<6F> got_timeoutrhrerfr(r^rgs f @@rr)<00>ThreadedHistory.load~s.<00><><00><00> <14> <20> <20> <20> )<29> 0<> 0<><1B>+<2B>+<2B><1B>!<0E>D<EFBFBD> <1D> <11> <1D> <1D> #<23> #<23> %<25> <20>!<21><04><1A><0F><0F>!<21><05> <0A> <09> <09> <0B> <0C> <20> <20>'<27>'<27><05>.<2E><19> <0A> 3<><16>%)<29>$8<>$8<><18>9<>%<12><12> <0B>#<23><1C>+<2B>+<2B>)-<2D>(<<3C>(<<3C>T<EFBFBD>;<3B>(O<>"O<><0F> <09><1D><13>Y<EFBFBD><1E>/<2F> <0A>%<25>D<EFBFBD><1E>J<EFBFBD>&<26><18>4<EFBFBD><19> <10> $<24> $<24> +<2B> +<2B>E<EFBFBD> 2<>1<12>#P<01><> <11> $<24> $<24> +<2B> +<2B>E<EFBFBD> 2<>sN<00>B E"<01>&E<00>D><04> E<00> "E<00>/E<04>0+E<00> E<00>!E"<01>>E<00>E<00>E<03>E"c<01><00>V^8<>dQhRR/#rr)rs"rrrL<00>s<00><00><1C><1C><14>rc  <09><><00>.VnVPP4F^pVP;_uu_4VPP V4RRR4VP
FpVP 4K K` VP;_uu_4RVnRRR4VP
FpVP 4K R# +'giL<>;i +'giLH;i TP;_uu_4RTnRRR4M +'giM;iTP
FpTP 4K i;i)NT)rrKr'rSrorTrnr)r r(r^s& rrk<00>ThreadedHistory._in_load_thread<61>s<><00><00> <1C>$&<26>D<EFBFBD> <20><1C> <0C> <0C>9<>9<>;<3B><04><19>Z<EFBFBD>Z<EFBFBD>Z<EFBFBD><18>(<28>(<28>/<2F>/<2F><04>5<> <20>"<22>5<>5<>E<EFBFBD><19>I<EFBFBD>I<EFBFBD>K<EFBFBD>6<> <<3C><16><1A><1A><1A>#<23><04> <0C><1C><1D>1<>1<><05><15> <09> <09> <0B>2<> <20>Z<EFBFBD><5A> <1C><1A><><14><1A><1A><1A>#<23><04> <0C><1C><1A><1A><1A><><1D>1<>1<><05><15> <09> <09> <0B>2<>sF<00>8C4<00>C<07>/C4<00>C!<05> C <0B>C4<00>! C1 <09>4E<03> D <09> E<03> D* <0A>%,Ec<01> <00>V^8<>dQhRRRR/#r1r)rs"rrrL<00>r4rc <09><><00>VP;_uu_4VPP^V4RRR4VPV4R# +'giL#;i)<02>N)rSrr6r7r8s&&rr9<00>ThreadedHistory.append_string<6E>s<<00><00> <11>Z<EFBFBD>Z<EFBFBD>Z<EFBFBD> <10> <20> <20> '<27> '<27><01>6<EFBFBD> 2<><18> <0C><19><19>&<26>!<21><18>Z<EFBFBD>s <00>A <05> A c<01><00>V^8<>dQhRR/#r<r)rs"rrrL<00>s<00><00>3<>3<>m<EFBFBD>3rc <09>6<00>VPP4#rN)rKr'rs&rr'<00>$ThreadedHistory.load_history_strings<67>s<00><00><13>|<7C>|<7C>0<>0<>2<>2rc<01> <00>V^8<>dQhRRRR/#r1r)rs"rrrL<00>s<00><00>*<2A>*<2A>3<EFBFBD>*<2A>4<EFBFBD>*rc <09><<00>VPPV4R#rN)rKr7r8s&&rr7<00>ThreadedHistory.store_string<6E>s<00><00> <0C> <0C> <0C>!<21>!<21>&<26>)rc<01><00>V^8<>dQhRR/#)rrr3r)rs"rrrL<00>s<00><00>4<>4<>#<23>4rc <09>$<00>RVP: R2#)zThreadedHistory(<28>))rKrs&r<00>__repr__<5F>ThreadedHistory.__repr__<5F>s<00><00>!<21>$<24>,<2C>,<2C>!1<><11>3<>3r)rPrrrSrTrK)rBrCrDrErFr!r)rkr9r'r7r<>rG<00> __classcell__<5F>rUs@rr r es6<00><><00><08> =<3D> =<3D>73<>r<1C>&"<22>3<>*<2A>4<>4rc<01>Na<00>]tRt^<5E>tRtR RV3RllltRRltRRltRtV;t #)
rz<>
:class:`.History` class that keeps a list of all strings in memory.
In order to prepopulate the history, it's possible to call either
`append_string` for all items or pass a list of strings to `__init__` here.
c<01> <00>V^8<>dQhRRRR/#)r<00>history_stringszSequence[str] | Nonerrr)rs"rr<00>InMemoryHistory.__annotate__<5F>s<00><00>2<>2<>(<<3C>2<><04>2rc <09>^<<01>\SV`4Vf
.VnR#\V4VnR#rN)rOr!<00>_storager&)r r<>rUs&&<26>rr!<00>InMemoryHistory.__init__<5F>s'<00><><00> <0A><07><18><1A> <1A> "<22><1E>D<EFBFBD>M<EFBFBD> <20><1F>1<>D<EFBFBD>Mrc<01><00>V^8<>dQhRR/#r<r)rs"rrr<><00>s<00><00>'<27>'<27>m<EFBFBD>'rc# <09>N"<00>VPRRR1,Rjx<01>L
R#L5i)Nr-<00>r<>rs&rr'<00>$InMemoryHistory.load_history_strings<67>s<00><00><00><17>=<3D>=<3D><14>2<EFBFBD><14>&<26>&<26>&<26>s <00>%<01>#<04>%c<01> <00>V^8<>dQhRRRR/#r1r)rs"rrr<><00>s<00><00>%<25>%<25>3<EFBFBD>%<25>4<EFBFBD>%rc <09><<00>VPPV4R#rN)r<>ror8s&&rr7<00>InMemoryHistory.store_string<6E>s<00><00> <0C> <0A> <0A><1C><1C>V<EFBFBD>$rr<>rN<00>
rBrCrDrErFr!r'r7rGr<>r<>s@rrr<00>s!<00><><00><08>2<>2<>'<27>%<25>%rc<01>><00>]tRt^<5E>tRtRRltRRltRRltRtR #)
r z:
:class:`.History` object that doesn't remember anything.
c<01><00>V^8<>dQhRR/#r<r)rs"rr<00>DummyHistory.__annotate__<5F>s<00><00><12><12>m<EFBFBD>rc <09><00>.#rNrrs&rr'<00>!DummyHistory.load_history_strings<67>s<00><00><11> rc<01> <00>V^8<>dQhRRRR/#r1r)rs"rrr<><00>s<00><00> <0A> <0A>3<EFBFBD> <0A>4<EFBFBD> rc <09><00>R#rNrr8s&&rr7<00>DummyHistory.store_string<6E>s<00><00> rc<01> <00>V^8<>dQhRRRR/#r1r)rs"rrr<><00>s<00><00> <0A> <0A>C<EFBFBD> <0A>D<EFBFBD> rc <09><00>R#rNrr8s&&rr9<00>DummyHistory.append_string<6E>s<00><00> rrN) rBrCrDrErFr'r7r9rGrrrr r <00>s<00><00><08><12> <0A> <0A> rzos.PathLike[str]zos.PathLike[bytes]c<01>Ja<00>]tRtRtRtRV3RlltRRltRRltR tV;t #)
r iz<
:class:`.History` class that stores all strings in a file.
c<01> <00>V^8<>dQhRRRR/#)r<00>filename<6D>_StrOrBytesPathrrr)rs"rr<00>FileHistory.__annotate__
s<00><00><1B><1B><1F><1B>T<EFBFBD>rc <09>0<<01>Wn\SV` 4R#rN)r<>rOr!)r r<>rUs&&<26>rr!<00>FileHistory.__init__
s<00><><00> <20> <0A> <0A><07><18>rc<01><00>V^8<>dQhRR/#r<r)rs"rrr<>s<00><00>!<21>!<21>m<EFBFBD>!rc <09><>aa<06>.o.oRVV3Rllp\PPVP4'd<>\ VPR4;_uu_4pVFPpVP RRR7pVP R4'dSPVR,4KGV!4.oKR V!4RRR4\S4# +'giL;i) c<01><00>V^8<>dQhRR/#rr)rs"rr<00>6FileHistory.load_history_strings.<locals>.__annotate__s<00><00> '<27> '<27>T<EFBFBD> 'rc<01>f<<02>S'd(RPS4RRpSPV4R#R#)<03>Nr-)<02>joinro)r2<00>lines<65>stringss <20><>r<00>add<64>-FileHistory.load_history_strings.<locals>.adds+<00><><00><14><1B><17><17><15><1E><03><12>,<2C><06><17><0E><0E>v<EFBFBD>&<26> r<00>rb<72>utf-8<>replace)<01>errors<72>+:<3A>NNN) <09>os<6F>path<74>existsr<73><00>open<65>decode<64>
startswithro<00>reversed)r r<><00>f<>
line_bytes<EFBFBD>liner<65>r<>s& @@rr'<00> FileHistory.load_history_stringss<><00><><00><1F><07><1D><05> '<27> '<27> <0E>7<EFBFBD>7<EFBFBD>><3E>><3E>$<24>-<2D>-<2D> (<28> (<28><15>d<EFBFBD>m<EFBFBD>m<EFBFBD>T<EFBFBD>*<2A>*<2A>a<EFBFBD>"#<23>J<EFBFBD>%<25>,<2C>,<2C>W<EFBFBD>Y<EFBFBD>,<2C>G<>D<EFBFBD><1B><EFBFBD><EFBFBD>s<EFBFBD>+<2B>+<2B><1D> <0C> <0C>T<EFBFBD>"<22>X<EFBFBD>.<2E><1B><05> "<22><05>#$<24><14><05>+<2B><18><07> <20> <20>+<2B>*<2A>s <00>AC<05> C c<01> <00>V^8<>dQhRRRR/#r1r)rs"rrr<>)s<00><00> $<24> $<24>3<EFBFBD> $<24>4<EFBFBD> $rc <09>(a<04>\VPR4;_uu_4oRV3RllpV!R\PP4 R24VP R4FpV!RV R24K RRR4R# +'giR#;i)<07>abc<01> <00>V^8<>dQhRRRR/#)r<00>tr3rrr)rs"rr<00>.FileHistory.store_string.<locals>.__annotate__-s<00><00> +<2B> +<2B><13> +<2B><14> +rc<01>H<<01>SPVPR44R#)r<>N)<02>write<74>encode)r<>r<>s&<26>rr<><00>'FileHistory.store_string.<locals>.write-s<00><><00><11><07><07><01><08><08><17>)<29>*rz
# <20>
r<EFBFBD>N)r<>r<><00>datetime<6D>now<6F>split)r r2r<>r<>r<>s&& @rr7<00>FileHistory.store_string)su<00><><00> <11>$<24>-<2D>-<2D><14> &<26> &<26>!<21> +<2B> +<2B> <12>D<EFBFBD><18>*<2A>*<2A>.<2E>.<2E>0<>1<><12>4<> 5<><1E> <0C> <0C>T<EFBFBD>*<2A><04><15><01>$<24><16>r<EFBFBD>l<EFBFBD>#<23>+<2B> '<27> &<26> &<26> &<26>s <00>AB<05> B )r<>r<>r<>s@rr r s!<00><><00><08><1B><1B>!<21>6 $<24> $r)r
r r r r)rF<00>
__future__rr<>r<>rQ<00>abcrr<00>asyncior<00>typingrrrr <00>__all__r
r rr r3<00>bytesr<73>r rrr<00><module>r<>s<><00><01><04>#<23><0F> <09><10>'<27>$<24><<3C><<3C> <02><07>E <0C><07>E <0C>Ps4<>g<EFBFBD>s4<>l%<25>g<EFBFBD>%<25>.  <0A>7<EFBFBD>  <0A> <18><03>U<EFBFBD>$6<>8L<38>L<>M<><0F>-$<24>'<27>-$r