• File: browser.cpython-37.pyc
  • Full Path: /home3/farmfre2/public_html/ALFA_DATA/alfasymlink/root/proc/self/root/opt/alt/python37/lib64/python3.7/idlelib/__pycache__/browser.cpython-37.pyc
  • Date Modified: 10/26/2026 8:08 PM
  • File size: 9.27 KB
  • MIME-type: text/x-bytecode.python
  • Charset: 8 bit
B

Njz @sdZddlZddlZddlZddlmZddlmZddlm	Z	m
Z
mZddlm
Z
dadddZGd	d
d
ZGddde
ZGd
dde
ZddZedkreejdkrddlmZeddddddlmZeedS)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)idleConf)pyshell)TreeNodeTreeItemScrolledCanvas)ListedToplevelcCsg}x|D]\}}|dks(|j|krt|dr|jr|j|krg}xP|jD]F}t|tdkrh|}n"|j}|j|jkr|jd|}||qNW|jdd|7_||qW|S)aTransform 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.
    The insertion order of the dictionary is assumed to have been in line
    number order, so sorting is not necessary.

    The current tree only calls this once per child_dict 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, )	itemsmodulehasattrrnametypeappendformatjoin)Z
child_dictmodnameZobskeyobjZsupersZsupZsnamer4/opt/alt/python37/lib64/python3.7/idlelib/browser.pytransform_childrens
rc@sBeZdZdZdddddZdddZd	d
ZddZd
dZdS)
ModuleBrowserz1Browse module classes and functions in IDLE.
    F)_htest_utestcCs$||_||_||_||_|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)masterpathrrinit)selfrrrrrrr__init__As
zModuleBrowser.__init__NcCs|j|jdS)z&Dismiss the window and the tree nodes.N)topZdestroynode)rZeventrrrcloseYs
zModuleBrowser.closec	Cs|j}|js|jstjnt|}|jatj	
t||_}|
d|j|d|j|jr|d||df||t}t|dd}t||ddd	}|jjdd
d|}t|jd||_}|js|| dS)
z3Create browser tkinter widgets, including the tree.ZWM_DELETE_WINDOWz<Escape>z+%d+%dZnormal
backgroundr)ZbgZhighlightthicknessZ	takefocusZboth)expandZfillN)!rrrrflistZPyShellFileListopen	file_openpyclbrZ_modulesclearrr!Zprotocolr#ZbindZgeometryZwinfo_rootxZwinfo_rootysettitleZ	focus_setrZCurrentThemeZGetHighlightrframeZpackrootnoderZcanvasr"updater')	rrootr(r!Zthemer%Zscitemr"rrrr^s.

zModuleBrowser.initcCs*|jdtj|j|jddS)zSet the window title.zModule Browser - zModule BrowserN)r!Zwm_titleosrbasenameZwm_iconname)rrrrr-}szModuleBrowser.settitlecCs
t|jS)z7Return a ModuleBrowserTreeItem as the root of the tree.)ModuleBrowserTreeItemr)rrrrr/szModuleBrowser.rootnode)N)	__name__
__module____qualname____doc__r r#rr-r/rrrrr:s
rc@sHeZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
dS)r5z~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)rr:rrrr szModuleBrowserTreeItem.__init__cCstj|jS)z5Return the module name as the text string to display.)r3rr4r:)rrrrGetTextszModuleBrowserTreeItem.GetTextcCsdS)z'Return the name of the icon to display.pythonr)rrrrGetIconNamesz!ModuleBrowserTreeItem.GetIconNamecCsdd|DS)z*Return ChildBrowserTreeItems for children.cSsg|]}t|qSr)ChildBrowserTreeItem).0rrrr
<listcomp>sz4ModuleBrowserTreeItem.GetSubList.<locals>.<listcomp>)listchildren)rrrr
GetSubListsz ModuleBrowserTreeItem.GetSubListcCs>tj|jdddkrdStj|js0dSt|jdS)z6Open a module in an editor window when double clicked.Nz.py)r3rnormcaser:existsr*)rrrr
OnDoubleClicks
z#ModuleBrowserTreeItem.OnDoubleClickcCstj|jdddkS)z!Return True if Python (.py) file.rCNz.py)r3rrDr:)rrrrIsExpandablesz"ModuleBrowserTreeItem.IsExpandablecCsntj|j\}}tj|\}}tj|dkr6gSyt||gtj}Wnt	k
rbgSXt
||S)z5Return sequenced classes and functions in the module.z.py)r3rsplitr:splitextrDr+Z
readmodule_exsysImportErrorr)rdirbaserZextZtreerrrrAsz"ModuleBrowserTreeItem.listchildrenN)r6r7r8r9r r;r=rBrFrGrArrrrr5sr5c@s@eZdZdZddZddZddZdd	Zd
dZdd
Z	dS)r>zsBrowser 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
isinstancer+ZFunction
isfunction)rrrrrr szChildBrowserTreeItem.__init__cCs$|j}|jrd|dSd|SdS)z1Return the name of the function/class to display.zdef z(...)zclass N)rrO)rrrrrr;szChildBrowserTreeItem.GetTextcCs|jr
dSdSdS)z'Return the name of the icon to display.r<ZfolderN)rO)rrrrr=sz ChildBrowserTreeItem.GetIconNamecCs|jjikS)z+Return True if self.obj has nested objects.)rchildren)rrrrrGsz!ChildBrowserTreeItem.IsExpandablecCsddt|jjDS)z*Return ChildBrowserTreeItems for children.cSsg|]}t|qSr)r>)r?rrrrr@sz3ChildBrowserTreeItem.GetSubList.<locals>.<listcomp>)rrrP)rrrrrBszChildBrowserTreeItem.GetSubListc	Cs<yt|jj}||jjWnttfk
r6YnXdS)z2Open module with file_open and position to lineno.N)r*rr:ZgotolinelinenoOSErrorAttributeError)rZeditrrrrFs
z"ChildBrowserTreeItem.OnDoubleClickN)
r6r7r8r9r r;r=rGrBrFrrrrr>sr>cCsHttjdkrtjd}nt}Gdddt}dd}t||dddS)Nr&c@seZdZddZdS)z'_module_browser.<locals>.Nested_in_funccSsdS)Nrrrrrnested_in_classz7_module_browser.<locals>.Nested_in_func.nested_in_classN)r6r7r8rTrrrrNested_in_funcsrVcSsGddd}dS)Nc@seZdZdS)z;_module_browser.<locals>.closure.<locals>.Nested_in_closureN)r6r7r8rrrrNested_in_closuresrWr)rWrrrclosuresz _module_browser.<locals>.closureT)r)lenrJargv__file__rr)parentr:rVrXrrr_module_browsersr]__main__r&)mainzidlelib.idle_test.test_browserF)	verbosityexit)run)N)r9r3r+rJZidlelib.configrZidlelibrZidlelib.treerrrZidlelib.windowrr*rrr5r>r]r6rYrZZunittestr_Zidlelib.idle_test.htestrcrrrr<module>
s&
 M4-