Returns the absolute path to a resource given by a relative path depending on the environment (EXE or Python)
18def resource_path(s_relative_path: str) -> str:
19 """!
20 @brief Returns the absolute path to a resource given by a relative path depending on the environment (EXE or Python)
21 @param s_relative_path : the relative path to a file or directory
22 @return absolute path to the resource
23 """
24 if hasattr(sys, "_MEIPASS"):
25
26 s_base_path = sys._MEIPASS
27 else:
28 s_base_path = os.path.abspath("../")
29 s_resource_path = os.path.join(s_base_path, s_relative_path)
30 log.debug("Resource Path (relative %s): %s", s_relative_path, s_resource_path)
31 return s_resource_path
32
33
34