Read __version__ string for an init file.
(init_file)
| 93 | |
| 94 | |
| 95 | def get_version_string(init_file): |
| 96 | """ |
| 97 | Read __version__ string for an init file. |
| 98 | """ |
| 99 | |
| 100 | with open(init_file, "r") as fp: |
| 101 | content = fp.read() |
| 102 | version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M) |
| 103 | if version_match: |
| 104 | return version_match.group(1) |
| 105 | |
| 106 | raise RuntimeError("Unable to find version string in %s." % (init_file)) |
| 107 | |
| 108 | |
| 109 | # alias for get_version_string |