having fun with paths
This commit is contained in:
parent
96dbd7a323
commit
263b343b24
3
aoc.py
3
aoc.py
@ -1,7 +1,8 @@
|
||||
import os
|
||||
import tools
|
||||
from typing import List, Any, Type
|
||||
|
||||
BASE_PATH = os.path.dirname(os.path.dirname(__file__))
|
||||
BASE_PATH = tools.get_script_dir()
|
||||
INPUTS_PATH = os.path.join(BASE_PATH, 'inputs')
|
||||
|
||||
|
||||
|
||||
18
tools.py
Normal file
18
tools.py
Normal file
@ -0,0 +1,18 @@
|
||||
import inspect
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
|
||||
def get_script_dir(follow_symlinks=True):
|
||||
if getattr(sys, 'frozen', False):
|
||||
path = os.path.abspath(sys.executable)
|
||||
else:
|
||||
if '__main__' in sys.modules and hasattr(sys.modules['__main__'], '__file__'):
|
||||
path = sys.modules['__main__'].__file__
|
||||
else:
|
||||
path = inspect.getabsfile(get_script_dir)
|
||||
|
||||
if follow_symlinks:
|
||||
path = os.path.realpath(path)
|
||||
|
||||
return os.path.dirname(path)
|
||||
Loading…
Reference in New Issue
Block a user