Skip to content

Commit 2a1f2ca

Browse files
author
Jacob Truman
committed
Fix issue parsing version
1 parent 51a9522 commit 2a1f2ca

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

buildrunner/config/loader.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import jinja2
2121

22+
from buildrunner import __version__ as buildrunner_version
2223
from buildrunner.errors import (
2324
BuildRunnerConfigurationError,
2425
BuildRunnerVersionError,
@@ -124,27 +125,15 @@ def _validate_version(config: dict) -> None:
124125
buildrunner. If the config version is greater than the buildrunner version or any parsing error occurs
125126
it will raise a buildrunner exception.
126127
"""
127-
buildrunner_version = None
128-
129128
if not os.path.exists(VERSION_FILE_PATH):
130129
LOGGER.warning(
131130
f"File {VERSION_FILE_PATH} does not exist. This could indicate an error with "
132131
f"the buildrunner installation. Unable to validate version."
133132
)
134133
return
135134

136-
with open(VERSION_FILE_PATH, "r", encoding="utf-8") as version_file:
137-
for line in version_file.readlines():
138-
if "__version__" in line:
139-
try:
140-
version_values = (
141-
line.split("=")[1].strip().replace("'", "").split(".")
142-
)
143-
buildrunner_version = f"{version_values[0]}.{version_values[1]}"
144-
except IndexError as exception:
145-
raise ConfigVersionFormatError(
146-
f'couldn\'t parse version from "{line}"'
147-
) from exception
135+
version_values = buildrunner_version.split(".")
136+
buildrunner_version = f"{version_values[0]}.{version_values[1]}"
148137

149138
if not buildrunner_version:
150139
raise BuildRunnerVersionError("unable to determine buildrunner version")

0 commit comments

Comments
 (0)