File: ExtractVersion.py

package info (click to toggle)
cli11 2.4.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 2,120 kB
  • sloc: cpp: 23,299; python: 129; sh: 64; makefile: 11; ruby: 7
file content (17 lines) | stat: -rwxr-xr-x 511 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env python3

import os
import re

base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
config_h = os.path.join(base_path, "include", "CLI", "Version.hpp")
data = {"MAJOR": 0, "MINOR": 0, "PATCH": 0}
reg = re.compile(r"^\s*#define\s+CLI11_VERSION_([A-Z]+)\s+([0-9]+).*$")

with open(config_h, "r") as fp:
    for l in fp:
        m = reg.match(l)
        if m:
            data[m.group(1)] = int(m.group(2))

print("{}.{}.{}".format(data["MAJOR"], data["MINOR"], data["PATCH"]))