def get_xdg_data_dirs(): """Get the paths for the XDG data directories.""" result = [get_xdg_data_home()] result.extend([x.encode('utf-8') for x in get_env_path( 'XDG_DATA_DIRS', default_data_path).decode('utf-8').split(os.pathsep)]) return result
def test_get_env_path_no_var(self): """Test that get_env_path returns the default when env var not set.""" fake_path = "C:\\Users\\Ñandú" fake_env_var = "fake_env_var" default = fake_path.encode(sys.getfilesystemencoding()) self.unset_fake_environ(fake_env_var) self.assertEqual(get_env_path(fake_env_var, default), default)
def test_get_env_path_var(self): """Test that get_env_path transforms an env var.""" fake_path = 'C:\\Users\\Ñandú' fake_env_var = 'FAKE_ENV_VAR' mbcs_path = fake_path.encode(sys.getfilesystemencoding()) self.tweak_env(fake_env_var, str(mbcs_path)) self.assertEqual(get_env_path(fake_env_var, "unexpected"), fake_path)
def get_xdg_data_dirs(): """Get the paths for the XDG data directories.""" result = [get_xdg_data_home()] result.extend([ x.encode('utf-8') for x in get_env_path('XDG_DATA_DIRS', default_data_path).decode( 'utf-8').split(os.pathsep) ]) return result
def get_xdg_data_home(): """Get the path for XDG data directory in user's HOME.""" return get_env_path('XDG_DATA_HOME', default_data_home)
def get_xdg_config_home(): """Get the path for XDG config directory in user's HOME.""" return get_env_path('XDG_CONFIG_HOME', default_config_home)
def get_xdg_cache_home(): """Get the path for XDG cache directory in user's HOME.""" return get_env_path('XDG_CACHE_HOME', default_cache_home)
def get_xdg_config_dirs(): """Get the paths for the XDG config directories.""" result = [get_xdg_config_home()] result.extend([x for x in get_env_path( 'XDG_CONFIG_DIRS', default_config_path).split(os.pathsep)]) return result