import inspect import os.path import sys def get_script_dir(follow_symlinks=True): """return path of the executed script""" 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) def compare(a: int, b: int) -> int: """compare to values, return -1 if a is smaller than b, 1 if a is greater than b, 0 is both are equal""" if a > b: return -1 elif b > a: return 1 else: return 0