Use proper OS-specific path uris in many more places

also move path.join into local_path and output_path to simplify use
This commit is contained in:
Fabian Dill
2020-08-25 13:22:47 +02:00
parent 08f8677433
commit 2096d6ae5b
7 changed files with 33 additions and 30 deletions

View File

@@ -61,9 +61,9 @@ def is_bundled() -> bool:
return getattr(sys, 'frozen', False)
def local_path(path):
def local_path(*path):
if local_path.cached_path:
return os.path.join(local_path.cached_path, path)
return os.path.join(local_path.cached_path, *path)
elif is_bundled():
if hasattr(sys, "_MEIPASS"):
@@ -77,15 +77,16 @@ def local_path(path):
import __main__
local_path.cached_path = os.path.dirname(os.path.abspath(__main__.__file__))
return os.path.join(local_path.cached_path, path)
return os.path.join(local_path.cached_path, *path)
local_path.cached_path = None
def output_path(path):
def output_path(*path):
if output_path.cached_path:
return os.path.join(output_path.cached_path, path)
return os.path.join(output_path.cached_path, *path)
output_path.cached_path = local_path(get_options()["general_options"]["output_path"])
path = os.path.join(output_path.cached_path, path)
path = os.path.join(output_path.cached_path, *path)
os.makedirs(os.path.dirname(path), exist_ok=True)
return path