def get_raw_profile(): profile_file = file_utils.get_profile_file() fp = file_utils.get_file_obj(profile_file, 'rb') cfg = None if fp: cfg = six.moves.configparser.SafeConfigParser() with fp: cfg.readfp(fp) return cfg
def test_get_file_functions(self, mocker): pv_config_dir = os.path.join(os.path.expanduser('~'), '.picovico') m = mocker.patch('picovico.cli.file_utils.get_user_directory_for_storage') m.return_value = pv_config_dir profile_file = pv_cli_file_utility.get_file_from_storage('profile.ini') assert profile_file == os.path.join(pv_config_dir, 'profile.ini') assert profile_file == pv_cli_file_utility.get_profile_file() session_file = pv_cli_file_utility.get_file_from_storage('session') assert profile_file != session_file assert session_file == os.path.join(pv_config_dir, 'session') assert session_file == pv_cli_file_utility.get_session_file() project_file = pv_cli_file_utility.get_file_from_storage('project') assert project_file != session_file != profile_file assert project_file == os.path.join(pv_config_dir, 'project') assert project_file == pv_cli_file_utility.get_project_file()
def write_profile_config(cfg, mode='w'): profile_file = file_utils.get_profile_file() fp = file_utils.get_file_obj(profile_file, mode=mode) with fp: cfg.write(fp) return cfg