#import logger import dataset class Project: def __init__(self,name="Testing"): self.name = name self.dim_names = [] self._selection_observers = [] self.current_selection = {} self.current_data=[] self.datasets=[] def attach(self, observer): if not observer in self._selection_observers: self._selection_observers.append(observer) def detach(self, observer): try: self.selection_observers.remove(observer) except ValueError: pass def notify(self, modifier=None): for observer in self.selection_observers: if modifier != observer: observer.update(self) def set_selection(self,dim_name,selection): current_selection = set(selection) self.current_selection[dim_name] = current_selection self.notify() def get_selection(self,sel_obj): return sel_obj.current_selection def add_dataset(self,dataset): self.datasets.append(dataset) for dim_name in dataset.ids.keys(): if dim_name not in self.dim_names: self.dim_names.append(dim_name) def suggest_dim_name(self,dim_name): if dim_name in self.dim_names: dim_name = dim_name + "_t" return dim_name c_p = Project()