def _load_project_type_class(self, path): """ Load a project type class from the config project folder directly. Notes ----- This is done directly, since using the EmptyProject would rewrite the value in the constructor. If the project found has not been registered as a valid project type, the EmptyProject type will be returned. Returns ------- spyder.plugins.projects.api.BaseProjectType Loaded project type class. """ fpath = osp.join(path, get_project_config_folder(), 'config', WORKSPACE + ".ini") project_type_id = EmptyProject.ID if osp.isfile(fpath): config = configparser.ConfigParser() config.read(fpath) project_type_id = config[WORKSPACE].get("project_type", EmptyProject.ID) EmptyProject._PARENT_PLUGIN = self project_types = self.get_project_types() project_type_class = project_types.get(project_type_id, EmptyProject) return project_type_class
def create_project_config_files(self): """ """ dic = self.CONFIG_SETUP path = osp.join(self.root_path, get_project_config_folder(), 'config') for key in dic: name = key defaults = dic[key]['defaults'] version = dic[key]['version'] self.CONF[key] = UserConfig(name, path, defaults=defaults, load=True, version=version)
def __init__(self, root_path): self.name = None self.root_path = root_path self.open_project_files = [] self.open_non_project_files = [] path = os.path.join(root_path, get_project_config_folder(), 'config') self.config = ProjectMultiConfig( PROJECT_NAME_MAP, path=path, defaults=PROJECT_DEFAULTS, load=True, version=PROJECT_CONF_VERSION, backup=True, raw_mode=True, remove_obsolete=False, )
def __init__(self, root_path, parent_plugin=None): self.plugin = parent_plugin self.root_path = root_path self.open_project_files = [] self.open_non_project_files = [] path = osp.join(root_path, get_project_config_folder(), 'config') self.config = ProjectMultiConfig( PROJECT_NAME_MAP, path=path, defaults=PROJECT_DEFAULTS, load=True, version=PROJECT_CONF_VERSION, backup=True, raw_mode=True, remove_obsolete=False, ) act_name = self.get_option("project_type") if not act_name: self.set_option("project_type", self.ID)
def _load_project_type_class(self, path): """ Load a project type class from the config project folder directly. Notes ----- This is done directly, since using the EmptyProject would rewrite the value in the constructor. If the project found has not been registered as a valid project type, the EmptyProject type will be returned. Returns ------- spyder.plugins.projects.api.BaseProjectType Loaded project type class. """ fpath = osp.join( path, get_project_config_folder(), 'config', WORKSPACE + ".ini") project_type_id = EmptyProject.ID if osp.isfile(fpath): config = configparser.ConfigParser() # Catch any possible error when reading the workspace config file. # Fixes spyder-ide/spyder#17621 try: config.read(fpath, encoding='utf-8') except Exception: pass # This is necessary to catch an error for projects created in # Spyder 4 or older versions. # Fixes spyder-ide/spyder17097 try: project_type_id = config[WORKSPACE].get( "project_type", EmptyProject.ID) except KeyError: pass EmptyProject._PARENT_PLUGIN = self project_types = self.get_project_types() project_type_class = project_types.get(project_type_id, EmptyProject) return project_type_class
def _load_project_type(self, path): """ Load a project type from the config project folder directly. Notes ----- This is done directly, since using the EmptyProject would rewrite the value in the constructor. """ fpath = osp.join(path, get_project_config_folder(), 'config', WORKSPACE + ".ini") project_type = EmptyProject.ID if osp.isfile(fpath): config = configparser.ConfigParser() config.read(fpath) project_type = config[WORKSPACE].get("project_type", EmptyProject.ID) return project_type
def __get_project_config_folder(self): """Return project configuration folder.""" return osp.join(self.root_path, get_project_config_folder())