def __init__(self, project): self.project = project self.files = None rawobserver = resourceobserver.ResourceObserver( self._changed, self._invalid, self._invalid, self._invalid, self._invalid) self.project.add_observer(rawobserver)
def _init_validation(self): self.objectdb.validate_files() observer = resourceobserver.ResourceObserver( changed=self._resource_changed, moved=self._resource_moved, removed=self._resource_moved) files = [] for path in self.objectdb.get_files(): resource = self.to_pyobject.path_to_resource(path) if resource is not None and resource.project == self.project: files.append(resource) self.observer = resourceobserver.FilteredResourceObserver( observer, files) self.objectdb.add_file_list_observer(_FileListObserver(self)) self.project.add_observer(self.observer)
def __init__(self, project, observe=True, underlined=False): """Construct an AutoImport object If `observe` is `True`, listen for project changes and update the cache. If `underlined` is `True`, underlined names are cached, too. """ self.project = project self.underlined = underlined self.names = project.data_files.read_data('globalnames') if self.names is None: self.names = {} project.data_files.add_write_hook(self._write) # XXX: using a filtered observer observer = resourceobserver.ResourceObserver(changed=self._changed, moved=self._moved, removed=self._removed) if observe: project.add_observer(observer)