rope.base.resourceobserver ========================== .. py:module:: rope.base.resourceobserver Classes ------- .. autoapisummary:: rope.base.resourceobserver.ResourceObserver rope.base.resourceobserver.FilteredResourceObserver rope.base.resourceobserver.ChangeIndicator Module Contents --------------- .. py:class:: 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. .. py:attribute:: changed :value: None .. py:attribute:: moved :value: None .. py:attribute:: created :value: None .. py:attribute:: removed :value: None .. py:method:: resource_changed(resource) It is called when the resource changes .. py:method:: resource_moved(resource, new_resource) It is called when a resource is moved .. py:method:: resource_created(resource) Is called when a new resource is created .. py:method:: resource_removed(resource) Is called when a new resource is removed .. py:method:: 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. .. py:class:: 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. .. py:attribute:: observer .. py:attribute:: resources .. py:method:: add_resource(resource) Add a resource to the list of interesting resources .. py:method:: remove_resource(resource) Add a resource to the list of interesting resources .. py:method:: clear_resources() Removes all registered resources .. py:method:: resource_changed(resource) .. py:method:: resource_moved(resource, new_resource) .. py:method:: resource_created(resource) .. py:method:: resource_removed(resource) .. py:method:: validate(resource) .. py:class:: ChangeIndicator .. py:method:: get_indicator(resource) Return the modification time and size of a `Resource`.