Sideband/sbapp/gv.py

17 lines
489 B
Python

import re
import os
def gv() -> str:
version_file = os.path.join(
os.path.dirname(__file__), "main.py"
)
version_file_data = open(version_file, encoding="utf-8").read()
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)