MCPcopy Create free account
hub / github.com/T-duality/PillOCR-python / get_absolute_path

Function get_absolute_path

utils/path_tools.py:4–16  ·  view source on GitHub ↗

Get the absolute path of the resource file

(relative_path)

Source from the content-addressed store, hash-verified

2import sys
3
4def get_absolute_path(relative_path):
5 """Get the absolute path of the resource file"""
6 try:
7 # Packaged environment
8 base_path = sys._MEIPASS
9 # Adapt to _internal directory for PyInstaller 6.0 and above
10 internal_path = os.path.join(base_path, '_internal')
11 if os.path.exists(os.path.join(internal_path, relative_path)):
12 base_path = internal_path
13 except Exception:
14 # Development environment
15 base_path = os.path.abspath(".")
16 return os.path.join(base_path, relative_path)

Callers 1

__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected