1
0
mirror of https://github.com/SoftEtherVPN/SoftEtherVPN.git synced 2024-09-13 07:13:00 +03:00
SoftEtherVPN/version.py
Davide Beatrici 63b841efc0 version.py: Fix CI failure on macOS by avoiding inline if statement
File "version.py", line 25
    print(version, end = end)
                       ^
SyntaxError: invalid syntax
2021-02-20 16:55:43 +01:00

32 lines
773 B
Python

import argparse
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--newline', action = 'store_true', help = 'Break line after printing version')
args = parser.parse_args()
if args.newline:
end = None
else:
end = ''
version = None
with open('CMakeLists.txt', 'r') as file:
for line in file:
if 'VERSION "' in line and '.${BUILD_NUMBER}"' in line:
line = line.replace('VERSION "', '')
line = line[0 : line.find('.${BUILD_NUMBER}"')].strip()
version = line
break
if version is None:
raise Exception('Unable to read version from CMakeLists.txt')
if len(version) == 0 or not '.' in version:
raise Exception('Bad version: "{0}"'.format(version))
print(version, end = end)
if __name__ == '__main__':
main()