3 ^c @s~ddlZddlZddlZdgZGdddZddZy ddlZWnek rXdZYn"Xej ej ej ddd ZdS) N Completerc@s6eZdZd ddZddZddZdd Zd d ZdS) rNcCs8|rt|t rtd|dkr(d|_n d|_||_dS)Nznamespace must be a dictionaryr)Z isinstanceZdictZ TypeError use_main_ns namespace)selfrr#/usr/lib64/python3.6/rlcompleter.py__init__'s zCompleter.__init__c Cs|jrtj|_|jsB|dkr>tr8tjdtjdSdSndS|dkrld|kr`|j ||_ n |j ||_ y |j |St k rdSXdS)Nrz Z.) r__main____dict__rZstrip_readline_availablereadlineZ insert_textZ redisplay attr_matchesmatchesglobal_matchesZ IndexError)rtextZstaterrrcompleteBs$   zCompleter.completecCst|r|d}|S)Nz()Zcallable)rvalwordrrr_callable_postfixaszCompleter._callable_postfixc Csddl}g}dh}t|}xT|jD]J}|d||kr"|j||dkrR|d}n|dkrb|d }|j|q"Wx^|jtjgD]N}xH|jD]<\}}|d||kr||kr|j||j|j ||qWq~W|S)Nr __builtins__finallytryz:FalseNoneTruebreakcontinuepasselsez >rr>rrrrrrr) keywordlenZkwlistaddappendrbuiltinsr Zitemsr) rrr rZseennrZnspacerrrrrfs(    zCompleter.global_matchescCsnddl}|jd|}|sgS|jdd\}}yt||j}Wntk rPgSXtt|}|jdt |dr|j d|j t |j g}t|} |dkrd} n|dkrd } nd} xx~|D]v} | d| |ko| o| d| d| k rd || f} yt|| } Wntk rYnX|j| | } |j| qW|sH| rJP| dkrZd } qd} qW|j|S) Nrz(\w+(\.\w+)*)\.(\w*)rir __class__r Z_Z__z%s.%s)rematchZgroupZevalrZ ExceptionZsetdirZdiscardhasattrr"Zupdateget_class_membersr&r!Zgetattrrr#Zsort)rrr'ZmZexprZattrZ thisobjectZwordsrr%Znoprefixrr(rrrrrsN          zCompleter.attr_matchesN)Z__name__Z __module__Z __qualname__rrrrrrrrrr&s  cCs2t|}t|dr.x|jD]}|t|}qW|S)N __bases__)r)r*r-r+)ZklassZretZbaserrrr+s   r+FcCs tjdSr,)r set_completerrrrrsr/T) Zatexitr$r Z__all__rr+r Z ImportErrorr r.rZregisterrrrrZ s