Commits

Anonymous committed 591917b

ignoring all symlinks inside project

Comments (0)

Files changed (2)

rope/base/project.py

         for pattern in self.ignored_patterns:
             if pattern.match(resource.path):
                 return True
+            path = os.path.join(resource.project.address,
+                                *resource.path.split('/'))
+            if os.path.islink(path):
+                return True
         return False
 
     def _get_compiled_patterns(self):

ropetest/projecttest.py

-import os
+import os.path
 import unittest
 
 from rope.base.exceptions import RopeError, ResourceNotFoundError
 from rope.base.libutils import path_to_resource
 from rope.base.project import Project, NoProject, _realpath
 from ropetest import testutils
-import rope.base.resourceobserver
+from rope.base.resourceobserver import ResourceObserver, FilteredResourceObserver
+
 
 
 class ProjectTest(unittest.TestCase):
         self.assertEquals(myfolder, path_to_resource(
                           self.project, myfolder.real_path, type='folder'))
 
+    def test_getting_files(self):
+        project2 = testutils.sample_project(folder_name='sampleproject2')
+        mod = project2.root.create_file('mod.py')
+        try:
+            path = os.path.join(self.project.address, 'linkedfile.txt')
+            os.symlink(mod.real_path, path)
+            files = self.project.root.get_files()
+            self.assertEquals(1, len(files))
+        finally:
+            testutils.remove_project(project2)
+
 
 class ResourceObserverTest(unittest.TestCase):
 
         sample_file = self.project.root.create_file('my_file.txt')
         sample_file.write('text')
         sample_observer = _SampleObserver()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(sample_observer,
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
                                                            [sample_file]))
         sample_file.remove()
         self.assertEquals(1, sample_observer.change_count)
         my_folder = root_folder.create_folder('my_folder')
         my_folder_observer = _SampleObserver()
         root_folder_observer = _SampleObserver()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(my_folder_observer,
+        self.project.add_observer(FilteredResourceObserver(my_folder_observer,
                                                            [my_folder]))
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(root_folder_observer,
+        self.project.add_observer(FilteredResourceObserver(root_folder_observer,
                                                            [root_folder]))
         my_file = my_folder.create_file('my_file.txt')
         self.assertEquals(1, my_folder_observer.change_count)
         root = self.project.root
         my_file = root.create_file('my_file.txt')
         sample_observer = _SampleObserver()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(sample_observer,
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
                                                            [my_file]))
         os.remove(my_file.real_path)
         self.project.validate(root)
         root = self.project.root
         my_file = root.create_file('my_file.txt')
         sample_observer = _SampleObserver()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(sample_observer,
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
                                                            [my_file]))
         self.project.validate(root)
         self.assertEquals(None, sample_observer.last_moved)
         my_folder = root.create_folder('myfolder')
         my_file = my_folder.create_file('myfile.txt')
         sample_observer = _SampleObserver()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(sample_observer,
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
                                                            [my_folder]))
         testutils.remove_recursively(my_folder.real_path)
         self.project.validate(root)
     def test_removing_and_adding_resources_to_filtered_observer(self):
         my_file = self.project.root.create_file('my_file.txt')
         sample_observer = _SampleObserver()
-        filtered_observer = rope.base.resourceobserver.FilteredResourceObserver(sample_observer)
+        filtered_observer = FilteredResourceObserver(sample_observer)
         self.project.add_observer(filtered_observer)
         my_file.write('1')
         self.assertEquals(0, sample_observer.change_count)
         my_file = self.project.root.create_file('my_file.txt')
         sample_observer = _SampleObserver()
         timekeeper = _MockChangeIndicator()
-        filtered_observer = rope.base.resourceobserver.FilteredResourceObserver(sample_observer, [my_file],
+        filtered_observer = FilteredResourceObserver(sample_observer, [my_file],
                                                      timekeeper=timekeeper)
         self.project.add_observer(filtered_observer)
         self._write_file(my_file.real_path)
         my_file = self.project.root.create_file('my_file.txt')
         sample_observer = _SampleObserver()
         timekeeper = _MockChangeIndicator()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(
+        self.project.add_observer(FilteredResourceObserver(
                                   sample_observer, [my_file],
                                   timekeeper=timekeeper))
         timekeeper.set_indicator(my_file, 1)
         file1 = root.create_file('file1.txt')
         file2 = root.create_file('file2.txt')
         sample_observer = _SampleObserver()
-        self.project.add_observer(rope.base.resourceobserver.FilteredResourceObserver(
+        self.project.add_observer(FilteredResourceObserver(
                                   sample_observer, [root, file1, file2]))
         os.remove(file1.real_path)
         os.remove(file2.real_path)
         my_folder = self.project.root.create_folder('my_folder')
         my_file = my_folder.create_file('my_file.txt')
         sample_observer = _SampleObserver()
-        filtered_observer = rope.base.resourceobserver.FilteredResourceObserver(
+        filtered_observer = FilteredResourceObserver(
             sample_observer, [my_folder, my_file])
         self.project.add_observer(filtered_observer)
         my_folder.move('new_folder')
         root = self.project.root
         my_file = self.project.get_file('my_file.txt')
         sample_observer = _SampleObserver()
-        self.project.add_observer(
-            rope.base.resourceobserver.FilteredResourceObserver(sample_observer, [my_file]))
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
+                                                           [my_file]))
         file(my_file.real_path, 'w').close()
         self.project.validate(root)
         self.assertEquals(my_file, sample_observer.last_created)
         root = self.project.root
         my_file = self.project.get_file('my_file.txt')
         sample_observer = _SampleObserver()
-        self.project.add_observer(
-            rope.base.resourceobserver.FilteredResourceObserver(sample_observer, [my_file]))
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
+                                                           [my_file]))
         file(my_file.real_path, 'w').close()
         self.project.validate(root)
         self.project.validate(root)
         file2 = self.project.get_file('file2.txt')
         file1.create()
         sample_observer = _SampleObserver()
-        self.project.add_observer(
-            rope.base.resourceobserver.FilteredResourceObserver(sample_observer, [file1, file2]))
+        self.project.add_observer(FilteredResourceObserver(sample_observer,
+                                                           [file1, file2]))
         file1.move(file2.path)
         self.assertEquals(2, sample_observer.change_count)
         self.assertEquals(file2, sample_observer.last_created)
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 ProjectModifiedEvent.java.
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.