Files
iaito/scripts/get_version.py

24 lines
824 B
Python
Raw Permalink Normal View History

2023-05-21 23:45:41 +02:00
#!/usr/bin/env python3
2018-10-02 13:21:39 +02:00
import os
import re
scripts_path = os.path.dirname(os.path.realpath(__file__))
2021-04-07 10:37:57 +02:00
pro_file_path = os.path.join(scripts_path, "..", "src", "Iaito.pro")
2018-10-02 13:21:39 +02:00
with open(pro_file_path, "r") as f:
pro_content = f.read()
def version_var_re(name):
return "^[ \t]*{}[ \t]*=[ \t]*(\d+)[ \t]*$".format(name)
2018-10-02 13:21:39 +02:00
2021-04-07 10:37:57 +02:00
m = re.search(version_var_re("IAITO_VERSION_MAJOR"), pro_content, flags=re.MULTILINE)
2018-10-02 13:21:39 +02:00
version_major = int(m.group(1)) if m is not None else 0
2021-04-07 10:37:57 +02:00
m = re.search(version_var_re("IAITO_VERSION_MINOR"), pro_content, flags=re.MULTILINE)
2018-10-02 13:21:39 +02:00
version_minor = int(m.group(1)) if m is not None else 0
2021-04-07 10:37:57 +02:00
m = re.search(version_var_re("IAITO_VERSION_PATCH"), pro_content, flags=re.MULTILINE)
2018-10-02 13:21:39 +02:00
version_patch = int(m.group(1)) if m is not None else 0
print("{}.{}.{}".format(version_major, version_minor, version_patch))