File: get_version.py

package info (click to toggle)
iaito 6.0.8%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 7,796 kB
  • sloc: cpp: 45,386; sh: 673; xml: 323; python: 234; makefile: 125; ansic: 9
file content (23 lines) | stat: -rwxr-xr-x 824 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
import os
import re

scripts_path = os.path.dirname(os.path.realpath(__file__))
pro_file_path = os.path.join(scripts_path, "..", "src", "Iaito.pro")

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)

m = re.search(version_var_re("IAITO_VERSION_MAJOR"), pro_content, flags=re.MULTILINE)
version_major = int(m.group(1)) if m is not None else 0

m = re.search(version_var_re("IAITO_VERSION_MINOR"), pro_content, flags=re.MULTILINE)
version_minor = int(m.group(1)) if m is not None else 0

m = re.search(version_var_re("IAITO_VERSION_PATCH"), pro_content, flags=re.MULTILINE)
version_patch = int(m.group(1)) if m is not None else 0

print("{}.{}.{}".format(version_major, version_minor, version_patch))