ok

Mini Shell

Direktori : /opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/idlelib/__pycache__/browser.cpython-36.pyc

3

*j�aY �@s�dZddlZddlmZddlZddlmZddlmZddl	m
Z
mZmZddl
mZdaddd	�ZGd
d�d�ZGdd
�d
e�ZGdd�de�Zdd�Zedkr�eej�dkr�ddlmZedddd�ddlmZee�dS)a8Module 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)
- add base classes to class browser tree
- finish removing limitation to x.py files (ModuleBrowserTreeItem)
�N)�_pyclbr)�idleConf)�pyshell)�TreeNode�TreeItem�ScrolledCanvas)�ListedToplevelcCs�g}x�|j�D]�\}}|dks(|j|krt|d�r�|jr�|j|kr�g}xP|jD]F}t|�td�krh|}n"|j}|j|jkr�|j�d|��}|j|�qNW|jdjdj|��7_|j|�qWt	|dd�d	�S)
a�Transform a child dictionary to an ordered sequence of objects.

    The dictionary maps names to pyclbr information objects.
    Filter out imported objects.
    Augment class names with bases.
    Sort objects by line number.

    The current tree only calls this once per child_dic as it saves
    TreeItems once created.  A future tree and tests might violate this,
    so a check prevents multiple in-place augmentations.
    N�super��.z({})z, cSs|jS)N)�lineno)�o�r�4/opt/alt/python36/lib64/python3.6/idlelib/browser.py�<lambda>6sz$transform_children.<locals>.<lambda>)�key)
�items�module�hasattrr	�name�type�append�format�join�sorted)Z
child_dict�modnameZobsr�objZsupersZsupZsnamerrr�transform_childrensrc@sBeZdZdZddd�dd�Zddd�Zd	d
�Zdd�Zd
d�ZdS)�
ModuleBrowserz1Browse module classes and functions in IDLE.
    F)�_htest�_utestcCs$||_||_||_||_|j�dS)azCreate a window for browsing a module's structure.

        Args:
            master: parent for widgets.
            path: full path of file to browse.
            _htest - bool; change box location when running htest.
            -utest - bool; suppress contents when running unittest.

        Global variables:
            file_open: Function used for opening a file.

        Instance variables:
            name: Module name.
            file: Full path and module with .py extension.  Used in
                creating ModuleBrowserTreeItem as the rootnode for
                the tree and subsequently in the children.
        N)�master�pathrr �init)�selfr!r"rr rrr�__init__@s
zModuleBrowser.__init__NcCs|jj�|jj�dS)z&Dismiss the window and the tree nodes.N)�topZdestroy�node)r$Zeventrrr�closeXs
zModuleBrowser.closec	Cs�|j}|jp|jstjntj|�}|jatj	j
�t|�|_}|j
d|j�|jd|j�|jr�|jd|j�|j�df�|j�|j�tj�}tj|d�d}t||ddd	�}|jjdd
d�|j�}t|jd|�|_}|js�|j�|j �dS)
z3Create browser tkinter widgets, including the tree.ZWM_DELETE_WINDOWz<Escape>z+%d+%d��Znormal�
backgroundr�)ZbgZhighlightthicknessZ	takefocusZboth)�expandZfillN)!r!rr r�flistZPyShellFileList�open�	file_open�pyclbrZ_modules�clearrr&Zprotocolr(ZbindZgeometryZwinfo_rootxZwinfo_rooty�settitleZ	focus_setrZCurrentThemeZGetHighlightr�frameZpack�rootnoderZcanvasr'�updater,)	r$�rootr-r&Zthemer*Zsc�itemr'rrrr#]s.

zModuleBrowser.initcCs*|jjdtjj|j��|jjd�dS)zSet the window title.zModule Browser - zModule BrowserN)r&Zwm_title�osr"�basenameZwm_iconname)r$rrrr2|szModuleBrowser.settitlecCs
t|j�S)z7Return a ModuleBrowserTreeItem as the root of the tree.)�ModuleBrowserTreeItemr")r$rrrr4�szModuleBrowser.rootnode)N)	�__name__�
__module__�__qualname__�__doc__r%r(r#r2r4rrrrr9s
rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)r:z~Browser tree for Python module.

    Uses TreeItem as the basis for the structure of the tree.
    Used by both browsers.
    cCs
||_dS)zdCreate a TreeItem for the file.

        Args:
            file: Full path and module name.
        N)�file)r$r?rrrr%�szModuleBrowserTreeItem.__init__cCstjj|j�S)z5Return the module name as the text string to display.)r8r"r9r?)r$rrr�GetText�szModuleBrowserTreeItem.GetTextcCsdS)z'Return the name of the icon to display.�pythonr)r$rrr�GetIconName�sz!ModuleBrowserTreeItem.GetIconNamecCsdd�|j�D�S)z*Return ChildBrowserTreeItems for children.cSsg|]}t|��qSr)�ChildBrowserTreeItem)�.0rrrr�
<listcomp>�sz4ModuleBrowserTreeItem.GetSubList.<locals>.<listcomp>)�listchildren)r$rrr�
GetSubList�sz ModuleBrowserTreeItem.GetSubListcCs>tjj|jdd��dkrdStjj|j�s0dSt|j�dS)z6Open a module in an editor window when double clicked.�Nz.py���)r8r"�normcaser?�existsr/)r$rrr�
OnDoubleClick�s
z#ModuleBrowserTreeItem.OnDoubleClickcCstjj|jdd��dkS)z!Return True if Python (.py) file.rHNz.pyrI)r8r"rJr?)r$rrr�IsExpandable�sz"ModuleBrowserTreeItem.IsExpandablecCsntjj|j�\}}tjj|�\}}tjj|�dkr6gSytj||gtj�}Wnt	k
rbgSXt
||�S)z5Return sequenced classes and functions in the module.z.py)r8r"�splitr?�splitextrJr0Z
readmodule_ex�sys�ImportErrorr)r$�dir�baserZextZtreerrrrF�sz"ModuleBrowserTreeItem.listchildrenN)r;r<r=r>r%r@rBrGrLrMrFrrrrr:�sr:c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)rCzsBrowser tree for child nodes within the module.

    Uses TreeItem as the basis for the structure of the tree.
    cCs ||_|j|_t|tj�|_dS)z5Create a TreeItem for a pyclbr class/function object.N)rr�
isinstancer0ZFunction�
isfunction)r$rrrrr%�szChildBrowserTreeItem.__init__cCs$|j}|jrd|dSd|SdS)z1Return the name of the function/class to display.zdef z(...)zclass N)rrU)r$rrrrr@�szChildBrowserTreeItem.GetTextcCs|jr
dSdSdS)z'Return the name of the icon to display.rAZfolderN)rU)r$rrrrB�sz ChildBrowserTreeItem.GetIconNamecCs|jjikS)z+Return True if self.obj has nested objects.)r�children)r$rrrrM�sz!ChildBrowserTreeItem.IsExpandablecCsdd�t|jj�D�S)z*Return ChildBrowserTreeItems for children.cSsg|]}t|��qSr)rC)rDrrrrrE�sz3ChildBrowserTreeItem.GetSubList.<locals>.<listcomp>)rrrV)r$rrrrG�szChildBrowserTreeItem.GetSubListcCs<yt|jj�}|j|jj�Wnttfk
r6YnXdS)z2Open module with file_open and position to lineno.N)r/rr?Zgotoliner�OSError�AttributeError)r$ZeditrrrrL�s
z"ChildBrowserTreeItem.OnDoubleClickN)
r;r<r=r>r%r@rBrMrGrLrrrrrC�srCcCsHttj�dkrtjd}nt}Gdd�dt�}dd�}t||dd�dS)Nr+c@seZdZdd�ZdS)z'_module_browser.<locals>.Nested_in_funccSsdS)Nrrrrr�nested_in_class�sz7_module_browser.<locals>.Nested_in_func.nested_in_classN)r;r<r=rYrrrr�Nested_in_func�srZcSsGdd�d�}dS)Nc@seZdZdS)z;_module_browser.<locals>.closure.<locals>.Nested_in_closureN)r;r<r=rrrr�Nested_in_closure�sr[r)r[rrr�closure�sz _module_browser.<locals>.closureT)r)�lenrP�argv�__file__rr)�parentr?rZr\rrr�_module_browser�sra�__main__r+)�mainzidlelib.idle_test.test_browser�F)�	verbosity�exit)�run)N)r>r8Zidlelibrr0rPZidlelib.configrrZidlelib.treerrrZidlelib.windowrr/rrr:rCrar;r]r^ZunittestrcZidlelib.idle_test.htestrgrrrr�<module>
s&
M4-

Zerion Mini Shell 1.0