diff options
Diffstat (limited to 'qutebrowser/utils/standarddir.py')
-rw-r--r-- | qutebrowser/utils/standarddir.py | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/qutebrowser/utils/standarddir.py b/qutebrowser/utils/standarddir.py index ccb61436f..fd8e0361a 100644 --- a/qutebrowser/utils/standarddir.py +++ b/qutebrowser/utils/standarddir.py @@ -77,12 +77,12 @@ def _unset_organization() -> Iterator[None]: def _init_config(args: Optional[argparse.Namespace]) -> None: """Initialize the location for configs.""" - typ = QStandardPaths.ConfigLocation + typ = QStandardPaths.StandardLocation.ConfigLocation path = _from_args(typ, args) if path is None: if utils.is_windows: app_data_path = _writable_location( - QStandardPaths.AppDataLocation) + QStandardPaths.StandardLocation.AppDataLocation) path = os.path.join(app_data_path, 'config') else: path = _writable_location(typ) @@ -128,7 +128,7 @@ def config_py() -> str: def _init_data(args: Optional[argparse.Namespace]) -> None: """Initialize the location for data.""" - typ = QStandardPaths.AppDataLocation + typ = QStandardPaths.StandardLocation.AppDataLocation path = _from_args(typ, args) if path is None: if utils.is_windows: @@ -136,7 +136,7 @@ def _init_data(args: Optional[argparse.Namespace]) -> None: path = os.path.join(app_data_path, 'data') elif sys.platform.startswith('haiku'): # HaikuOS returns an empty value for AppDataLocation - config_path = _writable_location(QStandardPaths.ConfigLocation) + config_path = _writable_location(QStandardPaths.StandardLocation.ConfigLocation) path = os.path.join(config_path, 'data') else: path = _writable_location(typ) @@ -168,12 +168,12 @@ def data(system: bool = False) -> str: def _init_cache(args: Optional[argparse.Namespace]) -> None: """Initialize the location for the cache.""" - typ = QStandardPaths.CacheLocation + typ = QStandardPaths.StandardLocation.CacheLocation path = _from_args(typ, args) if path is None: if utils.is_windows: # Local, not Roaming! - data_path = _writable_location(QStandardPaths.AppLocalDataLocation) + data_path = _writable_location(QStandardPaths.StandardLocation.AppLocalDataLocation) path = os.path.join(data_path, 'cache') else: path = _writable_location(typ) @@ -192,7 +192,7 @@ def _init_download(args: Optional[argparse.Namespace]) -> None: Note this is only the default directory as found by Qt. Therefore, we also don't create it. """ - typ = QStandardPaths.DownloadLocation + typ = QStandardPaths.StandardLocation.DownloadLocation path = _from_args(typ, args) if path is None: path = _writable_location(typ) @@ -207,9 +207,9 @@ def _init_runtime(args: Optional[argparse.Namespace]) -> None: """Initialize location for runtime data.""" if utils.is_mac or utils.is_windows: # RuntimeLocation is a weird path on macOS and Windows. - typ = QStandardPaths.TempLocation + typ = QStandardPaths.StandardLocation.TempLocation else: - typ = QStandardPaths.RuntimeLocation + typ = QStandardPaths.StandardLocation.RuntimeLocation path = _from_args(typ, args) if path is None: @@ -217,10 +217,10 @@ def _init_runtime(args: Optional[argparse.Namespace]) -> None: path = _writable_location(typ) except EmptyValueError: # Fall back to TempLocation when RuntimeLocation is misconfigured - if typ == QStandardPaths.TempLocation: + if typ == QStandardPaths.StandardLocation.TempLocation: raise path = _writable_location( # pragma: no cover - QStandardPaths.TempLocation) + QStandardPaths.StandardLocation.TempLocation) # This is generic, but per-user. # _writable_location makes sure we have a qutebrowser-specific subdir. @@ -262,10 +262,10 @@ def _writable_location(typ: QStandardPaths.StandardLocation) -> str: # Types we are sure we handle correctly below. assert typ in [ - QStandardPaths.ConfigLocation, QStandardPaths.AppLocalDataLocation, - QStandardPaths.CacheLocation, QStandardPaths.DownloadLocation, - QStandardPaths.RuntimeLocation, QStandardPaths.TempLocation, - QStandardPaths.AppDataLocation], typ_str + QStandardPaths.StandardLocation.ConfigLocation, QStandardPaths.StandardLocation.AppLocalDataLocation, + QStandardPaths.StandardLocation.CacheLocation, QStandardPaths.StandardLocation.DownloadLocation, + QStandardPaths.StandardLocation.RuntimeLocation, QStandardPaths.StandardLocation.TempLocation, + QStandardPaths.StandardLocation.AppDataLocation], typ_str with _unset_organization(): path = QStandardPaths.writableLocation(typ) @@ -280,7 +280,7 @@ def _writable_location(typ: QStandardPaths.StandardLocation) -> str: # Add the application name to the given path if needed. # This is in order for this to work without a QApplication (and thus # QStandardsPaths not knowing the application name). - if (typ != QStandardPaths.DownloadLocation and + if (typ != QStandardPaths.StandardLocation.DownloadLocation and path.split(os.sep)[-1] != APPNAME): path = os.path.join(path, APPNAME) @@ -297,12 +297,12 @@ def _from_args( The overridden path, or None if there is no override. """ basedir_suffix = { - QStandardPaths.ConfigLocation: 'config', - QStandardPaths.AppDataLocation: 'data', - QStandardPaths.AppLocalDataLocation: 'data', - QStandardPaths.CacheLocation: 'cache', - QStandardPaths.DownloadLocation: 'download', - QStandardPaths.RuntimeLocation: 'runtime', + QStandardPaths.StandardLocation.ConfigLocation: 'config', + QStandardPaths.StandardLocation.AppDataLocation: 'data', + QStandardPaths.StandardLocation.AppLocalDataLocation: 'data', + QStandardPaths.StandardLocation.CacheLocation: 'cache', + QStandardPaths.StandardLocation.DownloadLocation: 'download', + QStandardPaths.StandardLocation.RuntimeLocation: 'runtime', } if getattr(args, 'basedir', None) is None: |