mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
refactor: use pathlib /
separator rather than .joinpath
Mainly to help readability
This commit is contained in:
parent
eba30f3c17
commit
55850bfe2f
1 changed files with 5 additions and 5 deletions
|
@ -27,21 +27,21 @@ def get_resource_path(filename: str) -> str:
|
||||||
if getattr(sys, "dangerzone_dev", False):
|
if getattr(sys, "dangerzone_dev", False):
|
||||||
# Look for resources directory relative to python file
|
# Look for resources directory relative to python file
|
||||||
project_root = pathlib.Path(__file__).parent.parent
|
project_root = pathlib.Path(__file__).parent.parent
|
||||||
prefix = project_root.joinpath("share")
|
prefix = project_root / "share"
|
||||||
else:
|
else:
|
||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
bin_path = pathlib.Path(sys.executable)
|
bin_path = pathlib.Path(sys.executable)
|
||||||
app_path = bin_path.parent.parent
|
app_path = bin_path.parent.parent
|
||||||
prefix = app_path.joinpath("Resources", "share")
|
prefix = app_path / "Resources" / "share"
|
||||||
elif platform.system() == "Linux":
|
elif platform.system() == "Linux":
|
||||||
prefix = pathlib.Path(sys.prefix).joinpath("share", "dangerzone")
|
prefix = pathlib.Path(sys.prefix) / "share" / "dangerzone"
|
||||||
elif platform.system() == "Windows":
|
elif platform.system() == "Windows":
|
||||||
exe_path = pathlib.Path(sys.executable)
|
exe_path = pathlib.Path(sys.executable)
|
||||||
dz_install_path = exe_path.parent
|
dz_install_path = exe_path.parent
|
||||||
prefix = dz_install_path.joinpath("share")
|
prefix = dz_install_path / "share"
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"Unsupported system {platform.system()}")
|
raise NotImplementedError(f"Unsupported system {platform.system()}")
|
||||||
resource_path = prefix.joinpath(filename)
|
resource_path = prefix / filename
|
||||||
return str(resource_path)
|
return str(resource_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue