Exemple #1
0
 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)
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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
Exemple #5
0
 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
Exemple #6
0
 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
Exemple #7
0
 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)
Exemple #8
0
 def data(self):
     if rwa.islazy(self._data):
         self._data = self._data.peek(deep=True)
     return self._data