-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathMFilePath.py
35 lines (24 loc) · 1.06 KB
/
MFilePath.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import os
import pathlib
import sys
import SCOFunctions.AppFunctions as AF
def truePath(file: str) -> str:
""" Returns the path to the main directory regardless of the current working directory
For non-packaged run, this is assuming that MFilePath is in a direct subfolder of the main folder (hence double .parent)"""
if AF.isCompiled():
return os.path.normpath(os.path.join(AF.nuitka_exe_folder(), file))
if AF.isFrozen():
path = os.path.join(pathlib.Path(sys.executable).parent.absolute(), file)
return os.path.normpath(path)
path = os.path.join(pathlib.Path(__file__).parent.parent.absolute(), file)
return os.path.normpath(path)
def innerPath(file: str) -> str:
""" Gets path to a packaged file
Takes care of cases when it's packaged with pyinstaller.
"""
if AF.isCompiled():
return os.path.normpath(os.path.join(AF.nuitka_exe_folder(), file))
if AF.isFrozen():
path = os.path.join(pathlib.Path(sys.executable).parent.absolute(), file)
return os.path.normpath(path)
return file