def __init__(self, parent=None, active_project_callback=None): """ Configuration manager to provide access to user/site/project config. """ path = self.get_user_config_path() if not osp.isdir(path): os.makedirs(path) # Site configuration defines the system defaults if a file # is found in the site location conf_paths = get_conf_paths() site_defaults = DEFAULTS for conf_path in reversed(conf_paths): conf_fpath = os.path.join(conf_path, 'spyder.ini') if os.path.isfile(conf_fpath): site_config = UserConfig( 'spyder', path=conf_path, defaults=site_defaults, load=False, version=CONF_VERSION, backup=False, raw_mode=True, remove_obsolete=False, ) site_defaults = site_config.to_list() self._parent = parent self._active_project_callback = active_project_callback self._user_config = MultiUserConfig( NAME_MAP, path=path, defaults=site_defaults, load=True, version=CONF_VERSION, backup=True, raw_mode=True, remove_obsolete=False, ) # Store plugin configurations when CONF_FILE = True self._plugin_configs = {} # TODO: To be implemented in following PR self._project_configs = {} # Cache project configurations # Setup self.remove_deprecated_config_locations()
def __init__(self, parent=None, active_project_callback=None): """ Configuration manager to provide access to user/site/project config. """ path = self.get_user_config_path() if not osp.isdir(path): os.makedirs(path) # Site configuration defines the system defaults if a file # is found in the site location conf_paths = get_conf_paths() site_defaults = DEFAULTS for conf_path in reversed(conf_paths): conf_fpath = os.path.join(conf_path, 'spyder.ini') if os.path.isfile(conf_fpath): site_config = UserConfig( 'spyder', path=conf_path, defaults=site_defaults, load=False, version=CONF_VERSION, backup=False, raw_mode=True, remove_obsolete=False, ) site_defaults = site_config.to_list() self._parent = parent self._active_project_callback = active_project_callback self._user_config = MultiUserConfig( NAME_MAP, path=path, defaults=site_defaults, load=True, version=CONF_VERSION, backup=True, raw_mode=True, remove_obsolete=False, ) # Store plugin configurations when CONF_FILE = True self._plugin_configs = {} # TODO: To be implemented in following PR self._project_configs = {} # Cache project configurations # Object observer map # This dict maps from a configuration key (str/tuple) to a set # of objects that should be notified on changes to the corresponding # subscription key per section. The observer objects must be hashable. # # type: Dict[ConfigurationKey, Dict[str, Set[ConfigurationObserver]]] self._observers = {} # Set of suscription keys per observer object # This dict maps from a observer object to the set of configuration # keys that the object is subscribed to per section. # # type: Dict[ConfigurationObserver, Dict[str, Set[ConfigurationKey]]] self._observer_map_keys = weakref.WeakKeyDictionary() # Setup self.remove_deprecated_config_locations()