SILENT KILLERPanel

Current Path: > > opt > alt > python34 > lib64 > python3.4 > > idlelib >


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: //opt/alt/python34/lib64/python3.4//idlelib/

NameTypeSizeLast ModifiedActions
Icons Directory - -
__pycache__ Directory - -
idle_test Directory - -
AutoComplete.py File 9202 bytes April 17 2024 17:09:57.
AutoCompleteWindow.py File 17739 bytes April 17 2024 17:09:57.
AutoExpand.py File 3395 bytes April 17 2024 17:09:57.
Bindings.py File 3046 bytes April 17 2024 17:09:57.
CREDITS.txt File 1865 bytes March 18 2019 16:51:26.
CallTipWindow.py File 6034 bytes April 17 2024 17:09:57.
CallTips.py File 5932 bytes April 17 2024 17:09:57.
ChangeLog File 56393 bytes March 18 2019 16:51:26.
ClassBrowser.py File 6999 bytes April 17 2024 17:09:58.
CodeContext.py File 8348 bytes April 17 2024 17:09:57.
ColorDelegator.py File 9695 bytes April 17 2024 17:09:57.
Debugger.py File 18759 bytes April 17 2024 17:09:57.
Delegator.py File 665 bytes April 17 2024 17:09:57.
EditorWindow.py File 66059 bytes April 17 2024 17:09:57.
FileList.py File 3813 bytes April 17 2024 17:09:57.
FormatParagraph.py File 7287 bytes April 17 2024 17:09:58.
GrepDialog.py File 5124 bytes April 17 2024 17:09:58.
HISTORY.txt File 10317 bytes March 18 2019 16:51:26.
HyperParser.py File 12877 bytes April 17 2024 17:09:57.
IOBinding.py File 19773 bytes April 17 2024 17:09:57.
IdleHistory.py File 4052 bytes April 17 2024 17:09:58.
MultiCall.py File 18571 bytes April 17 2024 17:09:57.
MultiStatusBar.py File 1348 bytes April 17 2024 17:09:57.
NEWS.txt File 39835 bytes March 18 2019 16:51:26.
ObjectBrowser.py File 3975 bytes April 17 2024 17:09:57.
OutputWindow.py File 4394 bytes April 17 2024 17:09:58.
ParenMatch.py File 6713 bytes April 17 2024 17:09:57.
PathBrowser.py File 3207 bytes April 17 2024 17:09:57.
Percolator.py File 3244 bytes April 17 2024 17:09:58.
PyParse.py File 20461 bytes April 17 2024 17:09:57.
PyShell.py File 58450 bytes April 17 2024 17:09:57.
README.txt File 7709 bytes March 18 2019 16:51:26.
RemoteDebugger.py File 12007 bytes April 17 2024 17:09:57.
RemoteObjectBrowser.py File 964 bytes April 17 2024 17:09:57.
ReplaceDialog.py File 6640 bytes April 17 2024 17:09:57.
RstripExtension.py File 1050 bytes April 17 2024 17:09:57.
ScriptBinding.py File 8061 bytes April 17 2024 17:09:57.
ScrolledList.py File 4375 bytes April 17 2024 17:09:57.
SearchDialog.py File 2630 bytes April 17 2024 17:09:57.
SearchDialogBase.py File 7009 bytes April 17 2024 17:09:57.
SearchEngine.py File 7485 bytes April 17 2024 17:09:58.
StackViewer.py File 4426 bytes April 17 2024 17:09:58.
TODO.txt File 8478 bytes March 18 2019 16:51:26.
ToolTip.py File 3173 bytes April 17 2024 17:09:58.
TreeWidget.py File 15024 bytes April 17 2024 17:09:57.
UndoDelegator.py File 10815 bytes April 17 2024 17:09:57.
WidgetRedirector.py File 6869 bytes April 17 2024 17:09:57.
WindowList.py File 2472 bytes April 17 2024 17:09:57.
ZoomHeight.py File 1300 bytes April 17 2024 17:09:58.
__init__.py File 288 bytes April 17 2024 17:09:57.
__main__.py File 159 bytes April 17 2024 17:09:57.
aboutDialog.py File 6688 bytes April 17 2024 17:09:57.
config-extensions.def File 2965 bytes March 18 2019 16:51:26.
config-highlight.def File 2515 bytes March 18 2019 16:51:26.
config-keys.def File 7777 bytes March 18 2019 16:51:26.
config-main.def File 2563 bytes March 18 2019 16:51:26.
configDialog.py File 64305 bytes April 17 2024 17:09:57.
configHandler.py File 32197 bytes April 17 2024 17:09:57.
configHelpSourceEdit.py File 6670 bytes April 17 2024 17:09:57.
configSectionNameDialog.py File 4007 bytes April 17 2024 17:09:57.
dynOptionMenuWidget.py File 1990 bytes April 17 2024 17:09:57.
extend.txt File 3642 bytes March 18 2019 16:51:26.
help.html File 41126 bytes March 18 2019 16:51:26.
help.py File 9701 bytes April 17 2024 17:09:57.
help.txt File 17900 bytes March 18 2019 16:51:26.
idle.py File 400 bytes April 17 2024 17:09:57.
idle.pyw File 570 bytes March 18 2019 16:51:26.
idlever.py File 415 bytes April 17 2024 17:09:57.
keybindingDialog.py File 12416 bytes April 17 2024 17:09:57.
macosxSupport.py File 8684 bytes April 17 2024 17:09:57.
rpc.py File 20782 bytes April 17 2024 17:09:57.
run.py File 13673 bytes April 17 2024 17:09:57.
tabbedpages.py File 18418 bytes April 17 2024 17:09:57.
textView.py File 3225 bytes April 17 2024 17:09:57.

Reading File: //opt/alt/python34/lib64/python3.4//idlelib//ClassBrowser.py

"""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
"""

import os
import sys
import pyclbr

from idlelib import PyShell
from idlelib.WindowList import ListedToplevel
from idlelib.TreeWidget import TreeNode, TreeItem, ScrolledCanvas
from idlelib.configHandler import idleConf

file_open = None  # Method...Item and Class...Item use this.
# Normally PyShell.flist.open, but there is no PyShell.flist for htest.

class ClassBrowser:

    def __init__(self, flist, name, path, _htest=False):
        # XXX This API should change, if the file doesn't end in ".py"
        # XXX the code here is bogus!
        """
        _htest - bool, change box when location running htest.
        """
        global file_open
        if not _htest:
            file_open = PyShell.flist.open
        self.name = name
        self.file = os.path.join(path[0], self.name + ".py")
        self._htest = _htest
        self.init(flist)

    def close(self, event=None):
        self.top.destroy()
        self.node.destroy()

    def init(self, flist):
        self.flist = flist
        # reset pyclbr
        pyclbr._modules.clear()
        # create top
        self.top = top = ListedToplevel(flist.root)
        top.protocol("WM_DELETE_WINDOW", self.close)
        top.bind("<Escape>", self.close)
        if self._htest: # place dialog below parent if running htest
            top.geometry("+%d+%d" %
                (flist.root.winfo_rootx(), flist.root.winfo_rooty() + 200))
        self.settitle()
        top.focus_set()
        # create scrolled canvas
        theme = idleConf.CurrentTheme()
        background = idleConf.GetHighlight(theme, 'normal')['background']
        sc = ScrolledCanvas(top, bg=background, highlightthickness=0, takefocus=1)
        sc.frame.pack(expand=1, fill="both")
        item = self.rootnode()
        self.node = node = TreeNode(sc.canvas, None, item)
        node.update()
        node.expand()

    def settitle(self):
        self.top.wm_title("Class Browser - " + self.name)
        self.top.wm_iconname("Class Browser")

    def rootnode(self):
        return ModuleBrowserTreeItem(self.file)

class ModuleBrowserTreeItem(TreeItem):

    def __init__(self, file):
        self.file = file

    def GetText(self):
        return os.path.basename(self.file)

    def GetIconName(self):
        return "python"

    def GetSubList(self):
        sublist = []
        for name in self.listclasses():
            item = ClassBrowserTreeItem(name, self.classes, self.file)
            sublist.append(item)
        return sublist

    def OnDoubleClick(self):
        if os.path.normcase(self.file[-3:]) != ".py":
            return
        if not os.path.exists(self.file):
            return
        PyShell.flist.open(self.file)

    def IsExpandable(self):
        return os.path.normcase(self.file[-3:]) == ".py"

    def listclasses(self):
        dir, file = os.path.split(self.file)
        name, ext = os.path.splitext(file)
        if os.path.normcase(ext) != ".py":
            return []
        try:
            dict = pyclbr.readmodule_ex(name, [dir] + sys.path)
        except ImportError:
            return []
        items = []
        self.classes = {}
        for key, cl in dict.items():
            if cl.module == name:
                s = key
                if hasattr(cl, 'super') and cl.super:
                    supers = []
                    for sup in cl.super:
                        if type(sup) is type(''):
                            sname = sup
                        else:
                            sname = sup.name
                            if sup.module != cl.module:
                                sname = "%s.%s" % (sup.module, sname)
                        supers.append(sname)
                    s = s + "(%s)" % ", ".join(supers)
                items.append((cl.lineno, s))
                self.classes[s] = cl
        items.sort()
        list = []
        for item, s in items:
            list.append(s)
        return list

class ClassBrowserTreeItem(TreeItem):

    def __init__(self, name, classes, file):
        self.name = name
        self.classes = classes
        self.file = file
        try:
            self.cl = self.classes[self.name]
        except (IndexError, KeyError):
            self.cl = None
        self.isfunction = isinstance(self.cl, pyclbr.Function)

    def GetText(self):
        if self.isfunction:
            return "def " + self.name + "(...)"
        else:
            return "class " + self.name

    def GetIconName(self):
        if self.isfunction:
            return "python"
        else:
            return "folder"

    def IsExpandable(self):
        if self.cl:
            try:
                return not not self.cl.methods
            except AttributeError:
                return False

    def GetSubList(self):
        if not self.cl:
            return []
        sublist = []
        for name in self.listmethods():
            item = MethodBrowserTreeItem(name, self.cl, self.file)
            sublist.append(item)
        return sublist

    def OnDoubleClick(self):
        if not os.path.exists(self.file):
            return
        edit = file_open(self.file)
        if hasattr(self.cl, 'lineno'):
            lineno = self.cl.lineno
            edit.gotoline(lineno)

    def listmethods(self):
        if not self.cl:
            return []
        items = []
        for name, lineno in self.cl.methods.items():
            items.append((lineno, name))
        items.sort()
        list = []
        for item, name in items:
            list.append(name)
        return list

class MethodBrowserTreeItem(TreeItem):

    def __init__(self, name, cl, file):
        self.name = name
        self.cl = cl
        self.file = file

    def GetText(self):
        return "def " + self.name + "(...)"

    def GetIconName(self):
        return "python" # XXX

    def IsExpandable(self):
        return 0

    def OnDoubleClick(self):
        if not os.path.exists(self.file):
            return
        edit = file_open(self.file)
        edit.gotoline(self.cl.methods[self.name])

def _class_browser(parent): #Wrapper for htest
    try:
        file = __file__
    except NameError:
        file = sys.argv[0]
        if sys.argv[1:]:
            file = sys.argv[1]
        else:
            file = sys.argv[0]
    dir, file = os.path.split(file)
    name = os.path.splitext(file)[0]
    flist = PyShell.PyShellFileList(parent)
    global file_open
    file_open = flist.open
    ClassBrowser(flist, name, [dir], _htest=True)

if __name__ == "__main__":
    from idlelib.idle_test.htest import run
    run(_class_browser)

SILENT KILLER Tool