[eryntools] A new Python module full of useful utilities

Add a scripting module that implements absolute_script_path().
This commit is contained in:
Eryn Wells 2024-03-05 10:58:20 -08:00
parent ddf3de5a80
commit f64df23eda
2 changed files with 13 additions and 0 deletions

View file

@ -0,0 +1,2 @@
#!/usr/local/env python3
# Eryn Wells <eryn@erynwells.me>

View file

@ -0,0 +1,11 @@
# Eryn Wells <eryn@erynwells.me>
import os.path
import sys
from typing import Optional
def absolute_script_path(argv0: Optional[str] = None) -> Optional[str]:
'''Get the absolute path to the currently executing script.'''
executable = argv0 or sys.argv[0]
return os.path.abspath(executable) if executable else None