[Python-checkins] r65409 - in sandbox/trunk/ttk-gsoc/src/idlelib: ClassBrowser.py PathBrowser.py

guilherme.polo python-checkins at python.org
Sat Aug 2 16:11:53 CEST 2008


Author: guilherme.polo
Date: Sat Aug  2 16:11:53 2008
New Revision: 65409

Log:
Removed eminent cyclic module reference (EditorWindow -> editorpage -> PathBrowser -> ClassBrowser -> PyShell -> FileList -> EditorWindow)

Modified:
   sandbox/trunk/ttk-gsoc/src/idlelib/ClassBrowser.py
   sandbox/trunk/ttk-gsoc/src/idlelib/PathBrowser.py

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/ClassBrowser.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/ClassBrowser.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/ClassBrowser.py	Sat Aug  2 16:11:53 2008
@@ -14,7 +14,6 @@
 import sys
 import pyclbr
 
-import PyShell
 from WindowList import ListedToplevel
 from TreeWidget import TreeNode, TreeItem, ScrolledCanvas
 from configHandler import idleConf
@@ -26,6 +25,7 @@
         # XXX the code here is bogus!
         self.name = name
         self.file = os.path.join(path[0], self.name + ".py")
+        self.flist = None
         self.init(flist)
 
     def close(self, event=None):
@@ -57,12 +57,13 @@
         self.top.wm_iconname("Class Browser")
 
     def rootnode(self):
-        return ModuleBrowserTreeItem(self.file)
+        return ModuleBrowserTreeItem(self.file, self.flist)
 
 class ModuleBrowserTreeItem(TreeItem):
 
-    def __init__(self, file):
+    def __init__(self, file, flist):
         self.file = file
+        self.flist = flist
 
     def GetText(self):
         return os.path.basename(self.file)
@@ -73,7 +74,8 @@
     def GetSubList(self):
         sublist = []
         for name in self.listclasses():
-            item = ClassBrowserTreeItem(name, self.classes, self.file)
+            item = ClassBrowserTreeItem(name, self.classes, self.file, 
+                self.flist)
             sublist.append(item)
         return sublist
 
@@ -82,7 +84,7 @@
             return
         if not os.path.exists(self.file):
             return
-        PyShell.flist.open(self.file)
+        self.flist.open(self.file)
 
     def IsExpandable(self):
         return os.path.normcase(self.file[-3:]) == ".py"
@@ -122,10 +124,11 @@
 
 class ClassBrowserTreeItem(TreeItem):
 
-    def __init__(self, name, classes, file):
+    def __init__(self, name, classes, file, flist):
         self.name = name
         self.classes = classes
         self.file = file
+        self.flist = flist
         try:
             self.cl = self.classes[self.name]
         except (IndexError, KeyError):
@@ -163,7 +166,7 @@
     def OnDoubleClick(self):
         if not os.path.exists(self.file):
             return
-        edit = PyShell.flist.open(self.file)
+        edit = self.flist.open(self.file)
         if hasattr(self.cl, 'lineno'):
             lineno = self.cl.lineno
             edit.gotoline(lineno)
@@ -199,10 +202,11 @@
     def OnDoubleClick(self):
         if not os.path.exists(self.file):
             return
-        edit = PyShell.flist.open(self.file)
+        edit = self.flist.open(self.file)
         edit.gotoline(self.cl.methods[self.name])
 
 def main():
+    import PyShell
     try:
         file = __file__
     except NameError:

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/PathBrowser.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/PathBrowser.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/PathBrowser.py	Sat Aug  2 16:11:53 2008
@@ -15,25 +15,29 @@
         self.top.wm_iconname("Path Browser")
 
     def rootnode(self):
-        return PathBrowserTreeItem()
+        return PathBrowserTreeItem(self.flist)
 
 class PathBrowserTreeItem(TreeItem):
 
+    def __init__(self, flist):
+        self.flist = flist
+
     def GetText(self):
         return "sys.path"
 
     def GetSubList(self):
         sublist = []
         for dir in sys.path:
-            item = DirBrowserTreeItem(dir)
+            item = DirBrowserTreeItem(dir, flist=self.flist)
             sublist.append(item)
         return sublist
 
 class DirBrowserTreeItem(TreeItem):
 
-    def __init__(self, dir, packages=[]):
+    def __init__(self, dir, packages=[], flist=None):
         self.dir = dir
         self.packages = packages
+        self.flist = flist
 
     def GetText(self):
         if not self.packages:
@@ -55,10 +59,11 @@
         packages.sort()
         sublist = []
         for nn, name, file in packages:
-            item = DirBrowserTreeItem(file, self.packages + [name])
+            item = DirBrowserTreeItem(file, self.packages + [name], self.flist)
             sublist.append(item)
         for nn, name in self.listmodules(names):
-            item = ModuleBrowserTreeItem(os.path.join(self.dir, name))
+            item = ModuleBrowserTreeItem(os.path.join(self.dir, name), 
+                self.flist)
             sublist.append(item)
         return sublist
 


More information about the Python-checkins mailing list