def save_recent_path(path: str, cli_configs: dict): """ :param path: :param cli_configs: :return: """ if not path: return recent_paths = cli_configs.get('recent', []) recent_paths = list(filter((path).__ne__, recent_paths)) recent_paths.insert(0, path) cli_configs['recent'] = recent_paths[:5] system.save_configs(cli_configs)
def remove_key(configs: dict, key: str): """ Removes the specified key from the tracksim configs if the key exists :param configs: The tracksim configs object to modify :param key: The key in the tracksim configs object to remove """ if key in configs: del configs[key] system.save_configs(configs) system.log( '[REMOVED]: "{}" from configuration settings'.format(key) )
def set_key(configs: dict, key: str, value: typing.List[str]): """ Removes the specified key from the tracksim configs if the key exists :param configs: The tracksim configs object to modify :param key: The key in the tracksim configs object to remove :param value: """ if key.startswith('path.'): for index in range(len(value)): value[index] = paths.clean(value[index]) if len(value) == 1: value = value[0] configs[key] = value system.save_configs(configs) system.log('[SET]: "{}" to "{}"'.format(key, value))