3
fY @ s d Z ddlZddlmZ ddlZddlmZ ddlmZ ddl m
Z
mZmZ ddl
mZ daddd ZG d
d dZG dd
d
eZG dd deZdd ZedkreejdkrddlmZ edddd ddlmZ ee dS )a8 Module 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)TreeNodeTreeItemScrolledCanvas)ListedToplevelc C s g }x| j D ]\}}|dks(|j|krt|dr|jr|j|krg }xP|jD ]F}t|tdkrh|}n"|j}|j|jkr|j d| }|j| qNW | jdjdj|7 _|j| qW t |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.
Nsuper .z({})z, c S s | j S )N)lineno)o r 4/opt/alt/python36/lib64/python3.6/idlelib/browser.py6 s z$transform_children..)key)
itemsmodulehasattrr nametypeappendformatjoinsorted)Z
child_dictmodnameZobsr objZsupersZsupZsnamer r r transform_children s r c @ sB e Zd ZdZdddddZdddZd d
Zdd Zd
d ZdS )
ModuleBrowserz1Browse module classes and functions in IDLE.
F)_htest_utestc C s$ || _ || _|| _|| _| j dS )az Create 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)masterpathr r init)selfr! r" r r r r r __init__@ s
zModuleBrowser.__init__Nc C s | j j | jj dS )z&Dismiss the window and the tree nodes.N)topZdestroynode)r$ Zeventr r r closeX s
zModuleBrowser.closec C s | j }| jp| jstjntj|}|jatj j
t| | _}|j
d| j |jd| j | jr|jd|j |j d f | j |j tj }tj|dd }t||ddd }|jjdd
d | j }t|jd| | _}| js|j |j dS )
z3Create browser tkinter widgets, including the tree.ZWM_DELETE_WINDOWzz+%d+%d Znormal
backgroundr )ZbgZhighlightthicknessZ takefocusZboth)expandZfillN)!r! r r r flistZPyShellFileListopen file_openpyclbrZ_modulesclearr r&