1#!/usr/bin/env python
2
3""" Portable python script to read version from configure.acr """
4
5import sys
6
7full_version = False
8
9for arg in sys.argv[1:]:
10    if arg == '--full-version':
11        full_version = True
12    else:
13        print('Option %s not supported' % (arg,))
14        sys.exit(1)
15
16with open('configure.acr', 'r') as f:
17    f.readline()
18    version = f.readline().split()[1]
19    sys.stdout.write(version + '\n')
20    if full_version:
21        versions = version.split('.')
22        version_major = versions[0] if len(versions) > 0 else 0
23        version_minor = versions[1] if len(versions) > 1 else 0
24        version_patch = versions[2].replace('-git', '') if len(versions) > 2 else 0
25        version_number = "%d%02d%02d"%(int(version_major), int(version_minor), int(version_patch))
26        sys.stdout.write(version_major + '\n')
27        sys.stdout.write(version_minor + '\n')
28        sys.stdout.write(version_patch + '\n')
29        sys.stdout.write(version_number + '\n')
30