mirror of
https://github.com/markqvist/Sideband.git
synced 2024-12-26 07:59:23 -05:00
17 lines
495 B
Python
17 lines
495 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, "rt", 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)
|