B /g^!;c@sddlZddlZddlZddlZddlmZmZmZddddgZ iZ GdddZ Gd dde Z Gd dde Z d d Zdd dZdddZdddZdddZddZddZddZddZedkredS) N)NAMEDEDENTOP readmodule readmodule_exClassFunctionc@seZdZddZddZdS)_ObjectcCs(||_||_||_||_||_i|_dSN)modulenamefilelinenoparentchildrenselfr r r r rr/usr/lib64/python3.7/pyclbr.py__init__6s z_Object.__init__cC||j|<dSr )r)rr objrrr _addchild>z_Object._addchildN)__name__ __module__ __qualname__rrrrrrr4src@seZdZdddZdS)rNcCst||||||dSr )rrrrrrrDrzFunction.__init__r )rrrrrrrrrBscs&eZdZdfdd ZddZZS)rNcs0t|||||||dkr gn||_i|_dSr )rrsupermethods)rr r rr r rZ __class__rrrJszClass.__init__cCrr )r)rr r rrr _addmethodOrzClass._addmethodr )rrrrrZ __classcell__rrrrrHscCs:t|j||j||}|||t|tr6||||Sr )rr r r isinstancerr)ob func_namer Znewfuncrrr_nest_functionSs    r#cCs&t|j|||j||}||||Sr )rr r r)r! class_namer rZnewclassrrr _nest_class[s r%cCs:i}x0t||pgD]\}}t|tr|||<qW|Sr ) _readmoduleZitemsr r)r pathZreskeyZvaluerrrras   cCst||p gSr )r&)r r'rrrrmsc Cs`|dk rd||f}n|}|tkr*t|Si}|tjkrL|dkrL|t|<|S|d}|dkr|d|}||dd}t|||}|dk rd||f}d|krtd|t||d|Sd} |dk r|} n |tj} tj || } |t|<| j dk r| j |d<y| j |} | dkr$|SWnttfk r@|SX| j |} t||| | ||S)Nz%s.%s.rZ__path__zNo package named {})_modulessysZbuiltin_module_namesZrfindr& ImportErrorformatr' importlibZutilZ_find_spec_from_pathZsubmodule_search_locationsZloaderZ get_sourceZAttributeErrorZ get_filename _create_tree)r r' inpackage fullmoduletreeZiZpackageZ submodulerfZ search_pathZspecsourcefnamerrrr&vsF           r&c! Csjt|}g}t|j}y*x"|D]\} } } } } | tkrh| \}}x|rd|dd|krd|d=qHWq&| dkr| \}}x|r|dd|kr|d=q|Wt|dd\} }} | tkrq&d}|r|dd}t|||}nt ||||}|||<| ||fq&| dkr| \}}x$|r8|dd|kr8|d=qWt|dd\} }} | tkr\q&t|dd\} } } d}| dkrg}d}g}xt|dd\} } } | dkr2|dkr2d |}||kr||}nL| d }t |dkr$|d }|d}|tkr$t|}||kr$||}| |g}| dkrF|d7}nX| d krf|d8}|dkrPn8| d kr||dkr|n"| ttfkr|dkr| | qW|}|r|dd}t||||}nt|||||}|||<| ||fq&| dkr| ddkrt|}xl|D]d\}}yL|dkr8t||n2yt|||Wn tk rht|gYnXWn YnXqWq&| dkr&| ddkr&t|\}} |r&| dkrq&t|}yt|||}Wnw&YnXxd|D]\\}} ||kr|||| p|<n4|dkrx(|D] }|ddkr||||<qWqWq&WWntk r\YnX||S)Nir*ZdefriZclassz()),Zr)ir7r8ZimportZfrom*Z_)ioZStringIOtokenizeZgenerate_tokensZreadlinernextrr#rappendjoinZsplitZlenr+rr%r _getnamelistr&r-_getnameZ StopIterationZclose)!r2r'r6r5r3r1r4Zstackg tokentypetokenZstartZ_endZ_liner Z thisindentr"Zcur_funcZcur_objr$ZinheritnamesZlevelrZnZcZmZdZ cur_classZmodulesmodZ_mod2Zn2rrrr0s                             r0cCstg}xjt|\}}|sP|dkr.t|\}}nd}|||fx |dkr`d|kr`t|d}qBW|dkrPqW|S)NZasr8Z r*)r@r=r<)rArDr rCZname2rrrr?Bs r?cCsg}t|dd\}}|tkr0|dkr0d|fS||xJt|dd\}}|dkrZPt|dd\}}|tkrxP||q)rAZpartsrBrCrrrr@Xs r@c Csbddl}ytjd}Wnt}YnX|j|rj|j|g}|j|}| drn|dd}ng}t ||}dd}t | |dd}d }x|r\| }t|trqt|d sd|_t|trt |j |dd}x|D]} |j|| _qW||t|tr4td d |j|j|j|jqt|trtd d |j|j|jqWdS)Nrr*z.pyicSs t|ddS)Nr r)Zgetattr)ZarrrZysz_main..T)r(ZreverserFindentz{}class {} {} {}z z {}def {} {})osr,ZargvZ__file__r'ZexistsZdirnameZbasenameZlowerZendswithrZsortedZvaluesZpopr ZlistZhasattrrGrrZextendrZprintr.r rr r) rHrEr'r3Z lineno_keyZobjsZ indent_levelrZnew_objsr!rrr_mainjs@             rIZ__main__r r r r )r:r,Zimportlib.utilr/r;rCrrrZ__all__r+rrrr#r%rrr&r0r?r@rIrrrrrZ)s*    =&