Sideband/sbapp/gv.py

17 lines
489 B
Python
Raw Normal View History

2022-07-08 05:53:04 -06:00
import re
import os
def gv() -> str:
version_file = os.path.join(
os.path.dirname(__file__), "main.py"
)
2024-10-07 03:15:03 -06:00
version_file_data = open(version_file, encoding="utf-8").read()
2022-07-08 05:53:04 -06:00
version_regex = r"(?<=^__version__ = ['\"])[^'\"]+(?=['\"]$)"
try:
version = re.findall(version_regex, version_file_data, re.M)[0]
return version
except IndexError:
raise ValueError(f"Unable to find version string in {version_file}.")
print(gv(), end="")
exit(0)