[eryntools] A new Python module full of useful utilities
Add a scripting module that implements absolute_script_path().
This commit is contained in:
parent
ddf3de5a80
commit
f64df23eda
2 changed files with 13 additions and 0 deletions
2
Python/eryntools/src/eryntools/__init__.py
Normal file
2
Python/eryntools/src/eryntools/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/local/env python3
|
||||
# Eryn Wells <eryn@erynwells.me>
|
11
Python/eryntools/src/eryntools/scripting.py
Normal file
11
Python/eryntools/src/eryntools/scripting.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue