Fix version in docs for non-stable releases

develop
lethosor 2016-08-09 10:05:46 -04:00
parent 9c28d1a085
commit b211177a27
1 changed files with 7 additions and 4 deletions

@ -19,6 +19,7 @@ import fnmatch
from io import open from io import open
from itertools import starmap from itertools import starmap
import os import os
import re
import shlex # pylint:disable=unused-import import shlex # pylint:disable=unused-import
import sys import sys
@ -149,13 +150,15 @@ author = 'The DFHack Team'
def get_version(): def get_version():
"""Return the DFHack version string, from CMakeLists.txt""" """Return the DFHack version string, from CMakeLists.txt"""
version = release = '' #pylint:disable=redefined-outer-name version = release = '' #pylint:disable=redefined-outer-name
pattern = re.compile(r'set\((df_version|dfhack_release)\s+"(.+?)"\)')
try: try:
with open('CMakeLists.txt') as f: with open('CMakeLists.txt') as f:
for s in f.readlines(): for s in f.readlines():
if fnmatch.fnmatch(s.upper(), 'SET(DF_VERSION "?.??.??")\n'): for match in pattern.findall(s.lower()):
version = s.upper().replace('SET(DF_VERSION "', '') if match[0] == 'df_version':
elif fnmatch.fnmatch(s.upper(), 'SET(DFHACK_RELEASE "r*")\n'): version = match[1]
release = s.upper().replace('SET(DFHACK_RELEASE "', '').lower() elif match[0] == 'dfhack_release':
release = match[1]
return (version + '-' + release).replace('")\n', '') return (version + '-' + release).replace('")\n', '')
except IOError: except IOError:
return 'unknown' return 'unknown'