Anonymous avatar Anonymous committed 9c5c925

Adding base project to other projects' paths automatically

Comments (0)

Files changed (4)


-* Adding base to project classpaths; requires not changing
-  sys.classpath?
+* Adding base to project classpaths
 * Some refactorings return changes to out of project
 * resources Undoing Specifying the main project Adding
 * ``rope.refactor.multiproject.perform``


     def get_python_path_folders(self):
         result = []
-        for src in self.project.prefs.get('python_path', []) + sys.path:
+        for src in sys.path + self.project.prefs.get('python_path', []):
                 src_folder = rope.base.project.get_no_project().get_resource(src)


 class MultiProjectRefactoring(object):
-    def __init__(self, refactoring, projects):
+    def __init__(self, refactoring, projects, addpath=True):
         """Create a multiproject proxy for the main refactoring
         `projects` are other project.
         self.refactoring = refactoring
         self.projects = projects
+        self.addpath = addpath
     def __call__(self, project, *args, **kwds):
         """Create the refactoring"""
-        return _MultiRefactoring(self.refactoring, self.projects,
+        return _MultiRefactoring(self.refactoring, self.projects, self.addpath,
                                  project, *args, **kwds)
 class _MultiRefactoring(object):
-    def __init__(self, refactoring, other_projects, project, *args, **kwds):
+    def __init__(self, refactoring, other_projects, addpath,
+                 project, *args, **kwds):
         self.refactoring = refactoring
         self.projects = other_projects
         self.project = project
+        for other_project in self.projects:
+            other_project.get_prefs().add('python_path', self.project.address)
         self.main_refactoring = self.refactoring(project, *args, **kwds)
         args, kwds = self._change_project_resources_for_args(args, kwds)
         self.other_refactorings = [self.refactoring(other, *args, **kwds)


     def setUp(self):
         super(MultiProjectRefactoringTest, self).setUp()
         self.project1 = testutils.sample_project(foldername='testproject1')
-        self.project2 = testutils.sample_project(
-            foldername='testproject2', python_path=[self.project1.address])
+        self.project2 = testutils.sample_project(foldername='testproject2')
         self.mod1 = self.project1.root.create_file('')
         self.other = self.project1.root.create_file('')
         self.mod2 = self.project2.root.create_file('')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.