Read __version__ string for an init file.
(init_file)
| 119 | |
| 120 | |
| 121 | def get_version_string(init_file): |
| 122 | """ |
| 123 | Read __version__ string for an init file. |
| 124 | """ |
| 125 | |
| 126 | with open(init_file, "r") as fp: |
| 127 | content = fp.read() |
| 128 | version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M) |
| 129 | if version_match: |
| 130 | return version_match.group(1) |
| 131 | |
| 132 | raise RuntimeError("Unable to find version string in %s." % (init_file)) |
| 133 | |
| 134 | |
| 135 | # alias for get_version_string |