3
§ fY ã @ sä d Z ddlZddlmZ ddlZddlmZ ddlmZ ddl m
Z
mZmZ ddl
mZ daddd „ZG d
d„ dƒZG dd
„ d
eƒZG dd„ deƒZdd„ ZedkràeejƒdkrÌddlmZ 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)ÚTreeNodeÚTreeItemÚScrolledCanvas)ÚListedToplevelc C sÐ 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|ƒ 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.
NÚsuperÚ Ú.z({})z, c S s | j S )N)Úlineno)Úo© r ú4/opt/alt/python36/lib64/python3.6/idlelib/browser.pyÚ6 s z$transform_children..)Úkey)
ÚitemsÚmoduleÚhasattrr ÚnameÚtypeÚappendÚformatÚjoinÚsorted)Z
child_dictÚmodnameZobsr ÚobjZsupersZsupZsnamer r r Útransform_children s r c @ sB e Zd ZdZdddœdd„Zddd„Zd 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)ÚmasterÚpathr 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)ÚtopZdestroyÚnode)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|dƒd }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 ÚflistZPyShellFileListÚopenÚ file_openÚpyclbrZ_modulesÚclearr r&