Return the DFHack version string, from CMakeLists.txt
()
| 149 | # built documents. |
| 150 | |
| 151 | def get_version(): |
| 152 | """Return the DFHack version string, from CMakeLists.txt""" |
| 153 | version = release = '' #pylint:disable=redefined-outer-name |
| 154 | pattern = re.compile(r'set\((df_version|dfhack_release)\s+"(.+?)"\)') |
| 155 | try: |
| 156 | with open('CMakeLists.txt') as f: |
| 157 | for s in f.readlines(): |
| 158 | for match in pattern.findall(s.lower()): |
| 159 | if match[0] == 'df_version': |
| 160 | version = match[1] |
| 161 | elif match[0] == 'dfhack_release': |
| 162 | release = match[1] |
| 163 | return (version + '-' + release).replace('")\n', '') |
| 164 | except IOError: |
| 165 | return 'unknown' |
| 166 | |
| 167 | # The short X.Y version. |
| 168 | # The full version, including alpha/beta/rc tags. |