Your IP : 18.216.167.229


Current Path : /opt/alt/python34/lib64/python3.4/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/idlelib/__pycache__/ClassBrowser.cpython-34.pyc

�
f fW�@s
dZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
daGdd�d�ZGd	d
�d
e
�ZGdd�de
�ZGd
d�de
�Zdd�ZedkrddlmZee�ndS)a�Class browser.

XXX TO DO:

- reparse when source changed (maybe just a button would be OK?)
    (or recheck on window popup)
- add popup menu with more options (e.g. doc strings, base classes, imports)
- show function argument list? (have to do pattern matching on source)
- should the classes and methods lists also be in the module's menu bar?
- add base classes to class browser tree
�N)�PyShell)�ListedToplevel)�TreeNode�TreeItem�ScrolledCanvas)�idleConfc@sReZdZddd�Zddd�Zdd�Zd	d
�Zdd�ZdS)
�ClassBrowserFcCs[|stjjan||_tjj|d|jd�|_||_	|j
|�dS)zH
        _htest - bool, change box when location running htest.
        rz.pyN)r�flist�open�	file_open�name�os�path�join�file�_htest�init)�selfr	rrr�r�9/opt/alt/python34/lib64/python3.4/idlelib/ClassBrowser.py�__init__s	#	zClassBrowser.__init__NcCs|jj�|jj�dS)N)�topZdestroy�node)rZeventrrr�close)s
zClassBrowser.closecCs8||_tjj�t|j�|_}|jd|j�|j	d|j�|j
r�|jd|jj�|jj
�df�n|j�|j�tj�}tj|d�d}t|d|dd	d
d�}|jjddd
d�|j�}t|jd|�|_}|j�|j�dS)NZWM_DELETE_WINDOWz<Escape>z+%d+%d��Znormal�
backgroundZbgZhighlightthicknessrZ	takefocus��expandZfillZboth)r	�pyclbrZ_modules�clearr�rootrZprotocolrZbindrZgeometryZwinfo_rootxZwinfo_rooty�settitleZ	focus_setrZCurrentThemeZGetHighlightrZframeZpack�rootnoderZcanvasr�updater)rr	rZthemerZsc�itemrrrrr-s$	
		'


zClassBrowser.initcCs+|jjd|j�|jjd�dS)NzClass Browser - z
Class Browser)rZwm_titlerZwm_iconname)rrrrr!DszClassBrowser.settitlecCs
t|j�S)N)�ModuleBrowserTreeItemr)rrrrr"HszClassBrowser.rootnode)�__name__�
__module__�__qualname__rrrr!r"rrrrrs
rc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r%cCs
||_dS)N)r)rrrrrrMszModuleBrowserTreeItem.__init__cCstjj|j�S)N)r
r�basenamer)rrrr�GetTextPszModuleBrowserTreeItem.GetTextcCsdS)N�pythonr)rrrr�GetIconNameSsz!ModuleBrowserTreeItem.GetIconNamecCsFg}x9|j�D]+}t||j|j�}|j|�qW|S)N)�listclasses�ClassBrowserTreeItem�classesr�append)r�sublistrr$rrr�
GetSubListVs
z ModuleBrowserTreeItem.GetSubListcCsYtjj|jdd��dkr)dStjj|j�sBdStjj|j�dS)N�z.py���)r
r�normcaser�existsrr	r
)rrrr�
OnDoubleClick]s
%z#ModuleBrowserTreeItem.OnDoubleClickcCs#tjj|jdd��dkS)Nr3z.pyr4)r
rr5r)rrrr�IsExpandabledsz"ModuleBrowserTreeItem.IsExpandablec
Cs�tjj|j�\}}tjj|�\}}tjj|�dkrOgSy tj||gtj�}Wnt	k
r�gSYnXg}i|_
x|j�D]�\}}|j|kr�|}	t
|d�rp|jrpg}
xp|jD]e}t|�td�kr|}n1|j}|j|jkrEd|j|f}n|
j|�q�W|	ddj|
�}	n|j|j|	f�||j
|	<q�q�W|j�g}
x!|D]\}}	|
j|	�q�W|
S)Nz.py�super�z%s.%sz(%s)z, )r
r�splitr�splitextr5rZ
readmodule_ex�sys�ImportErrorr/�items�module�hasattrr9�typerr0r�lineno�sort)r�dirrrZext�dictr?�key�cl�sZsupersZsupZsname�listr$rrrr-gs< 
				
z!ModuleBrowserTreeItem.listclassesN)
r&r'r(rr*r,r2r7r8r-rrrrr%Ksr%c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r.cCsr||_||_||_y|j|j|_Wn!ttfk
rUd|_YnXt|jtj�|_	dS)N)
rr/rrH�
IndexError�KeyError�
isinstancerZFunction�
isfunction)rrr/rrrrr�s			zClassBrowserTreeItem.__init__cCs'|jrd|jdSd|jSdS)Nzdef z(...)zclass )rNr)rrrrr*�s	zClassBrowserTreeItem.GetTextcCs|jr
dSdSdS)Nr+Zfolder)rN)rrrrr,�s	z ClassBrowserTreeItem.GetIconNamecCs9|jr5y|jjSWq5tk
r1dSYq5XndS)NF)rH�methods�AttributeError)rrrrr8�s
	
z!ClassBrowserTreeItem.IsExpandablecCsS|js
gSg}x9|j�D]+}t||j|j�}|j|�q W|S)N)rH�listmethods�MethodBrowserTreeItemrr0)rr1rr$rrrr2�s	zClassBrowserTreeItem.GetSubListcCsZtjj|j�sdSt|j�}t|jd�rV|jj}|j|�ndS)NrC)	r
rr6rrrArHrC�gotoline)r�editrCrrrr7�sz"ClassBrowserTreeItem.OnDoubleClickcCs�|js
gSg}x3|jjj�D]\}}|j||f�q&W|j�g}x!|D]\}}|j|�q`W|S)N)rHrOr?r0rD)rr?rrCrJr$rrrrQ�s	
z ClassBrowserTreeItem.listmethodsN)
r&r'r(rr*r,r8r2r7rQrrrrr.�s
	r.c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rRcCs||_||_||_dS)N)rrHr)rrrHrrrrr�s		zMethodBrowserTreeItem.__init__cCsd|jdS)Nzdef z(...))r)rrrrr*�szMethodBrowserTreeItem.GetTextcCsdS)Nr+r)rrrrr,�sz!MethodBrowserTreeItem.GetIconNamecCsdS)Nrr)rrrrr8�sz"MethodBrowserTreeItem.IsExpandablecCsFtjj|j�sdSt|j�}|j|jj|j�dS)N)	r
rr6rrrSrHrOr)rrTrrrr7�sz#MethodBrowserTreeItem.OnDoubleClickN)r&r'r(rr*r,r8r7rrrrrR�s
rRcCs�y
t}WnOtk
r[tjd}tjdd�rJtjd}n
tjd}YnXtjj|�\}}tjj|�d}tj	|�}|j
at|||gdd�dS)NrrrT)
�__file__�	NameErrorr=�argvr
rr;r<rZPyShellFileListr
rr)�parentrrErr	rrr�_class_browser�s


	rY�__main__)�run)�__doc__r
r=rZidlelibrZidlelib.WindowListrZidlelib.TreeWidgetrrrZidlelib.configHandlerrrrr%r.rRrYr&Zidlelib.idle_test.htestr[rrrr�<module>s 2=<

?>