def allocate_effect_id(self, *srcs): """Allocate effect ID which is not taken in specified sources. Args: *srcs: List of source aliases. Returns: Allocated effect ID. """ if not srcs: srcs = [SourceManager.default.alias] return max( SourceManager.get(src).cache_handler.allocate_effect_id() for src in srcs)
def source(self, new_source): # Attempt to fetch source from source manager if passed object is not # instance of source class if not isinstance(new_source, Source) and new_source is not None: new_source = SourceManager.get(new_source) old_source = self.source if new_source is old_source: return if old_source is not None: for fit in self.fits: fit._unload_items() self.__source = new_source if new_source is not None: for fit in self.fits: fit._load_items()
def mkattr(self, *args, src=None, **kwargs): """Make attribute and add it to default source. Args: src (optional): Source alias to which attribute should be added. Default source is used by default. *args: Arguments which will be used to instantiate attribute. **kwargs: Keyword arguments which will be used to instantiate attribute. Returns: Attribute. """ if src is None: src = SourceManager.default else: src = SourceManager.get(src) return src.cache_handler.mkattr(*args, **kwargs)