1. Aviv Ben-Yosef
  2. rope


Ali Gholami Rudi  committed d3298cc

Adding exceptions module for less module dependencies

  • Participants
  • Parent commits dac7ce4
  • Branches trunk

Comments (0)

Files changed (6)

File docs/workingon.txt

View file
 *** Auto-complete imports names @ 3 ***
-- Throwing Exceptions when encountering errors
-- What if current line has errors
-- Test not proposing the variables in current line
 * What if the statement in current line is spread in more than one line
 * Extract listbox; duplicates in editor and core
 * Complete as you type (updating proposal list while typing)

File rope/codeassist.py

View file
 import compiler
-import rope.core
+from rope.exceptions import RopeException
-class RopeSyntaxError(rope.core.RopeException):
+class RopeSyntaxError(RopeException):
 class CompletionProposal(object):
     global_variable = 'global_variable'
         compiler.walk(code_ast, visitor)
         return result.values()

File rope/core.py

View file
 from threading import Thread
 from Tkinter import *
-from rope.fileeditor import FileEditor
-from rope.editor import GraphicalEditor
+import rope.editor
+import rope.fileeditor
+from rope.exceptions import RopeException
 from rope.project import Project, FileFinder, PythonFileRunner
-class RopeException(Exception):
-    '''Base exception for rope'''
-    pass
 class EditorManager(object):
     def __init__(self, editor_panel, core):
         self.core = core
             if editor.get_file() == file_:
                 return editor
-        editor = FileEditor(Core.get_core().get_open_project(), file_,
-                            GraphicalEditor(self.editor_frame))
+        editor = rope.fileeditor.FileEditor(Core.get_core().get_open_project(), file_,
+                                            rope.editor.GraphicalEditor(self.editor_frame))
         title = Radiobutton(self.editor_list, text=file_.get_name(),

File rope/exceptions.py

View file
+class RopeException(Exception):
+    '''Base exception for rope'''
+    pass

File rope/project.py

View file
 import sys
 import subprocess
-import rope.core
+from rope.exceptions import RopeException
 import rope.codeassist
 class Project(object):
         if not os.path.exists(self.root):
         elif not os.path.isdir(self.root):
-            raise rope.core.RopeException('Project root exists and is not a directory')
+            raise RopeException('Project root exists and is not a directory')
         self.code_assist = rope.codeassist.CodeAssist()
     def get_root_folder(self):
     def get_resource(self, resourceName):
         path = self._get_resource_path(resourceName)
         if not os.path.exists(path):
-            raise rope.core.RopeException('resource %s does not exist' % resourceName)
+            raise RopeException('resource %s does not exist' % resourceName)
         if os.path.isfile(path):
             return File(self, resourceName)
         if os.path.isdir(path):
             return Folder(self, resourceName)
-        raise rope.core.RopeException('Unknown resource ' + resourceName)
+        raise RopeException('Unknown resource ' + resourceName)
     def get_files(self):
         return self._get_files_recursively(self.get_root_folder())
         filePath = self._get_resource_path(fileName)
         if os.path.exists(filePath):
             if not os.path.isfile(filePath):
-                raise rope.core.RopeException('File already exists')
+                raise RopeException('File already exists')
-                raise rope.core.RopeException('A folder with the same name as this file already exists')
+                raise RopeException('A folder with the same name as this file already exists')
             newFile = open(filePath, 'w')
         except IOError, e:
-            raise rope.core.RopeException(e)
+            raise RopeException(e)
     def _create_folder(self, folderName):
         folderPath = self._get_resource_path(folderName)
         if os.path.exists(folderPath):
             if not os.path.isdir(folderPath):
-                raise rope.core.RopeException('A file with the same name as this folder already exists')
+                raise RopeException('A file with the same name as this folder already exists')
-                raise rope.core.RopeException('Folder already exists')
+                raise RopeException('Folder already exists')
     def _get_resource_path(self, name):
             init_dot_py_file = self.get_resource(init_dot_py)
             if not init_dot_py_file.is_folder():
                 return True
-        except rope.core.RopeException:
+        except RopeException:
         return False

File ropetest/projecttest.py

View file
 import os
 from rope.project import Project, FileFinder, PythonFileRunner
-from rope.core import RopeException
+from rope.exceptions import RopeException
 class SampleProjectMaker(object):
     def __init__(self):