Ë ‚Ö¦i“ãóè—dZddlZddlZddlZddlZddlZddlZdgZGd„d«Zd„Z ddl Z e je«j«ejd„«dZy#e$rdZYywxYw) a1Word completion for GNU readline. The completer completes keywords, built-ins and globals in a selectable namespace (which defaults to __main__); when completing NAME.NAME..., it evaluates (!) the expression up to the last dot and completes its attributes. It's very cool to do "import sys" type "sys.", hit the completion key (twice), and see the list of names defined by the sys module! Tip: to use the tab key as the completion key, call readline.parse_and_bind("tab: complete") Notes: - Exceptions raised by the completer function are *ignored* (and generally cause the completion to fail). This is a feature -- since readline sets the tty device in raw (or cbreak) mode, printing a traceback wouldn't work well without some complicated hoopla to save, reset and restore the tty state. - The evaluation of the NAME.NAME... form may cause arbitrary application defined code to be executed if an object with a __getattr__ hook is found. Since it is the responsibility of the application (or the user) to enable this feature, I consider this an acceptable risk. More complicated expressions (e.g. function calls or indexing operations) are *not* evaluated. - When the original stdin is not a tty device, GNU readline is never used, and this module (and the readline module) are silently inactive. éNÚ Completercó,—eZdZdd„Zd„Zd„Zd„Zd„Zy)rNcón—|rt|t«s td«‚|€d|_yd|_||_y)aáCreate a new completer for the command line. Completer([namespace]) -> completer instance. If unspecified, the default namespace where completions are performed is __main__ (technically, __main__.__dict__). Namespaces should be given as dictionaries. Completer instances should be used as the completion mechanism of readline via the set_completer() call: readline.set_completer(Completer(my_namespace).complete) znamespace must be a dictionaryNér)Ú isinstanceÚdictÚ TypeErrorÚ use_main_nsÚ namespace)Úselfr s ú$/usr/lib64/python3.12/rlcompleter.pyÚ__init__zCompleter.__init__*s;€ñ œZ¨ ´4Ô8ÜÐ<Ó=Ð =ð Ð Ø ˆDÕ à ˆDÔ Ø&ˆD�Nócó|—|jrtj|_|j «s7|dk(r1t r*t jd«t j«yyy|dk(r1d|vr|j|«|_ n|j|«|_ |j|S#t$rYywxYw)zÂReturn the next possible completion for 'text'. This is called successively with state == 0, 1, 2, ... until it returns None. The completion should begin with 'text'. rÚ ÚNÚ.) r Ú__main__Ú__dict__r ÚstripÚ_readline_availableÚreadlineÚ insert_textÚ redisplayÚ attr_matchesÚmatchesÚglobal_matchesÚ IndexError)r ÚtextÚstates r ÚcompletezCompleter.completeEs¨€ð × Ò Ü%×.Ñ.ˆDŒNà�z‰zŒ|ؘŠzÝ&Ü×(Ñ(¨Ô.Ü×&Ñ&Ô(Øààà �AŠ:Ø�d‰{Ø#×0Ñ0°Ó6�• à#×2Ñ2°4Ó8�” ð Ø—<‘< Ñ&Ð &øÜò Ùð ús B/Â/ B;Â:B;có”—t|«r,|dz } tj|«js|dz }|S|S#t$rY|SwxYw)NÚ(Ú))ÚcallableÚinspectÚ signatureÚ parametersÚ ValueError)r ÚvalÚwords r Ú_callable_postfixzCompleter._callable_postfixdsX€Ü �CŒ=Ø �C‰KˆDð Ü×(Ñ(¨Ó-×8Ò8ؘC‘K�Dðˆ ˆtˆ øôò Øàˆ ð ús’$:º AÁAcóà—g}dh}t|«}tjtjzD]@}|d||k(sŒ |j |«|dvr|dz}n |dvr|dz}|j |«ŒB|j tjfD]Z}|j«D]E\}}|d||k(sŒ||vsŒ|j |«|j |j||««ŒGŒ\|S)z²Compute matches when text is a simple name. Return a list of all keywords, built-in functions and names currently defined in self.namespace that match. Ú __builtins__N>ÚtryÚfinallyÚ:>Ú_ÚNoneÚTrueÚelseÚpassÚFalseÚbreakÚcontinueÚ ) ÚlenÚkeywordÚkwlistÚ softkwlistÚaddÚappendr ÚbuiltinsrÚitemsr,)r rrÚseenÚnr+Únspacer*s r rzCompleter.global_matchesosñ€ðˆØÐˆÜ �‹IˆÜ—N‘N¤W×%7Ñ%7Ô7ˆDØ�B�Qˆx˜4ÓØ—‘˜”ØÐ-Ñ-Ø #™:‘DØð"/ñ/ð  #™:�DØ—‘˜tÕ$ð8ð—~‘~¤x×'8Ñ'8Ó9ˆFØ#Ÿ\™\ž^‘ ��cؘ˜�8˜tÓ#¨°DÒ(8Ø—H‘H˜T”NØ—N‘N 4×#9Ñ#9¸#¸tÓ#DÕEñ,ð:ð ˆrcó:—tjd|«}|sgS|jdd«\}} t||j«}t t|««}|jd«t|d«r5|jd«|jt|j««g}t|«}|dk(rd} n |dk(rd} nd } |D]˜} | d ||k(sŒ | r | d |dz| k(rŒ|›d | ›�} tt!t#|«| d «t$«r|j'| «ŒWt!|| d «x} �"|j'|j)| | ««Œˆ|j'| «Œš|s| sn | dk(rd} nd } Œ­|j+«|S#t $rgcYSwxYw) a¿Compute matches when text contains a dot. Assuming the text is of the form NAME.NAME....[NAME], and is evaluable in self.namespace, it will be evaluated and its attributes (as revealed by dir()) are used as possible completions. (For class instances, class members are also considered.) WARNING: this can still invoke arbitrary C code, if an object with a __getattr__ hook is evaluated. z(\w+(\.\w+)*)\.(\w*)rér.Ú __class__rr2Ú__Nr)ÚreÚmatchÚgroupÚevalr Ú ExceptionÚsetÚdirÚdiscardÚhasattrr?ÚupdateÚget_class_membersrHr;rÚgetattrÚtypeÚpropertyr@r,Úsort) r rÚmÚexprÚattrÚ thisobjectÚwordsrrDÚnoprefixr+rKÚvalues r rzCompleter.attr_matchesŠsŸ€ô �H‰HÐ,¨dÓ 3ˆÙ؈IØ—W‘W˜Q “]‰ ˆˆdð ܘd D§N¡NÓ3ˆJô ”C˜ “OÓ$ˆØ � ‰ �nÔ%ä �:˜{Ô +Ø �I‰I�kÔ "Ø �L‰LÔ*¨:×+?Ñ+?Ó@Ô AØˆÜ �‹IˆØ �2Š:؉HØ �SŠ[؉HàˆHØÛ�ؘ˜!�H Ó$Ù! d¨4¨A¨a©C j°HÓ&<Ú'+©TÐ2�EÜ!¤'¬$¨zÓ*:¸DÀ$Ó"GÜ"*ô,ð Ÿ™ uÔ-Ø Ü!(¨°T¸4Ó!@Ð@˜ÐMØŸ™ t×'=Ñ'=¸eÀUÓ'KÕLàŸ™ uÕ-ð#ñ$™hØØ˜3ŠØ‘à�ð1ð2 � ‰ ŒØˆøôYò ØŠIð ús±F Æ FÆF©N)Ú__name__Ú __module__Ú __qualname__rr!r,rr©rr rr)s„ó'ò6ò> òó6>rcór—t|«}t|d«r|jD]}|t|«z}Œ|S)NÚ __bases__)rPrRrfrT)ÚklassÚretÚbases r rTrTÊs8€Ü ˆe‹*€C܈u�[Ô!Ø—O”OˆDØÔ)¨$Ó/Ñ/‰Cð$à €Jrcó,—tjd«Sr`)rÚ set_completerrdrr ÚrlÚs€œH×2Ñ2°4Ô8rTF)Ú__doc__ÚatexitrAr&r<rJrÚ__all__rrTrrkr!ÚregisterrÚ ImportErrorrdrr Úrrs‡ðñó>ÛÛÛÛ Ûà ˆ-€÷_ñ_òBð Ûð€H×Ñ™9›;×/Ñ/Ô0ð€F‡O�OÑ8Ô9ØÑøðò ØÒð ús¬A'Á'A1Á0A1