1. Alex Willmer
  2. rope

Commits

Ali Gholami Rudi  committed a4e6e09

autoimport: handled removed resources

  • Participants
  • Parent commits 10cf79e
  • Branches trunk

Comments (0)

Files changed (2)

File rope/contrib/autoimport.py

View file
         project.data_files.add_write_hook(self.write)
         # XXX: handle moved and removed
         observer = resourceobserver.ResourceObserver(
-            changed=self._changed, moved=self._moved)
+            changed=self._changed, moved=self._moved, removed=self._removed)
         if observe:
             project.add_observer(observer)
 
             if modname in self.names:
                 del self.names[modname]
             self.update_resource(newresource)
+
+    def _removed(self, resource):
+        if not resource.is_folder():
+            modname = self._module_name(resource)
+            if modname in self.names:
+                del self.names[modname]

File ropetest/contrib/autoimporttest.py

View file
         self.mod1.move('mod3.py')
         self.assertEquals(['mod3'], self.importer.get_modules('myvar'))
 
+    def test_removing_files(self):
+        self.mod1.write('myvar = None\n')
+        self.mod1.remove()
+        self.assertEquals([], self.importer.get_modules('myvar'))
+
 
 if __name__ == '__main__':
     unittest.main()