rope.base.resourceobserver
Classes
Provides the interface for observing resources |
|
A useful decorator for ResourceObserver |
|
Module Contents
- class rope.base.resourceobserver.ResourceObserver(changed=None, moved=None, created=None, removed=None, validate=None)
Provides the interface for observing resources
ResourceObserver can be registered using Project. add_observer(). But most of the time FilteredResourceObserver should be used. ResourceObserver report all changes passed to them and they don’t report changes to all resources. For example if a folder is removed, it only calls removed() for that folder and not its contents. You can use FilteredResourceObserver if you are interested in changes only to a list of resources. And you want changes to be reported on individual resources.
- changed = None
- moved = None
- created = None
- removed = None
- resource_changed(resource)
It is called when the resource changes
- resource_moved(resource, new_resource)
It is called when a resource is moved
- resource_created(resource)
Is called when a new resource is created
- resource_removed(resource)
Is called when a new resource is removed
- validate(resource)
Validate the existence of this resource and its children.
This function is called when rope need to update its resource cache about the files that might have been changed or removed by other processes.
- class rope.base.resourceobserver.FilteredResourceObserver(resource_observer, initial_resources=None, timekeeper=None)
A useful decorator for ResourceObserver
Most resource observers have a list of resources and are interested only in changes to those files. This class satisfies this need. It dispatches resource changed and removed messages. It performs these tasks:
Changes to files and folders are analyzed to check whether any of the interesting resources are changed or not. If they are, it reports these changes to resource_observer passed to the constructor.
When a resource is removed it checks whether any of the interesting resources are contained in that folder and reports them to resource_observer.
When validating a folder it validates all of the interesting files in that folder.
Since most resource observers are interested in a list of resources that change over time, add_resource and remove_resource might be useful.
- observer
- resources
- add_resource(resource)
Add a resource to the list of interesting resources
- remove_resource(resource)
Add a resource to the list of interesting resources
- clear_resources()
Removes all registered resources
- resource_changed(resource)
- resource_moved(resource, new_resource)
- resource_created(resource)
- resource_removed(resource)
- validate(resource)