3 \ @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) isinstancedict 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)Nr .) r__main____dict__rstrip_readline_availablereadlineZ insert_textZ redisplay attr_matchesmatchesglobal_matches IndexError)r textstater r r completeBs$   zCompleter.completecCst|r|d}|S)N()callable)r valwordr r r _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__finallytry:FalseNoneTruebreakcontinuepasselse >r"r#>r&r)r%r'r+r*r() keywordlenkwlistaddappendrbuiltinsritemsr ) r rr-rseennrZnspacerr r r rfs(    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*)rr! __class__r___z%s.%s)rematchgroupevalr Exceptionsetdirdiscardhasattrr0updateget_class_membersr7r.getattrr r1sort)r rr:mexprattrZ thisobjectZwordsrr5Znoprefixrr;rr r r rsN          zCompleter.attr_matches)N)__name__ __module__ __qualname__r rr rrr r r r r&s  cCs2t|}t|dr.x|jD]}|t|}qW|S)N __bases__)r@rBrMrD)klassZretbaser r r rDs   rDFcCs tjdS)N)r set_completerr r r r srQT) atexitr2r__all__rrDr ImportErrorrrPrregisterr r r r  s