def comments(self): if rwa.islazy(self._comments): self._comments = self._comments.deep() if rwa.islazy(self._metadata): self._metadata = self._metadata.deep() if rwa.islazy(self._instances): self._instances = self._instances.shallow() return base.CommentsView(self)
def metadata(self): if rwa.islazy(self._metadata): self._metadata = self._metadata.deep() if rwa.islazy(self._comments): self._comments = self._comments.deep() if rwa.islazy(self._instances): self._instances = self._instances.shallow() if self._metadata is None: self._metadata = {} return self._metadata
def __delitem__(self, label): if rwa.islazy(self._instances): self._instances = self._instances.shallow() if rwa.islazy(self._comments): self._comments = self._comments.deep() self._instances.__delitem__(label) try: self._comments.__delitem__(label) except KeyError: pass
def __getitem__(self, label): instance = base.InstancesView.__getitem__(self, label) if rwa.islazy(instance): if issubclass(instance.type, base.Analyses): instance = instance.shallow() self.__setitem__(label, instance) elif self.peek: instance = instance.deep() self.__setitem__(label, instance) return instance
def get(self, label, default=None): instance = base.InstancesView.get(self, label, None) if instance is None: instance = default elif rwa.islazy(instance): if issubclass(instance.type, base.Analyses): instance = instance.shallow() self.__setitem__(label, instance) elif self.peek: instance = instance.deep() self.__setitem__(label, instance) return instance
def _terminate(obj, ok=False): if rwa.islazy(obj): if ok: obj.store.handle = None else: obj.store.close() ok = True elif isinstance(obj, Analyses): obj = obj._instances if isinstance(obj, dict): # implicit: not rwa.islazy(obj) for k in obj: ok |= _terminate(obj[k], ok) else: ok |= _terminate(obj, ok) return ok
def instances(self): if rwa.islazy(self._instances): self._instances = self._instances.shallow() if rwa.islazy(self._comments): self._comments = self._comments.deep() return InstancesView(self)
def data(self): if rwa.islazy(self._data): self._data = self._data.peek(deep=True) return self._data