From 18edb9d61c92bd5c4e4b65a7c98fd1fd3eeff118 Mon Sep 17 00:00:00 2001 From: Iikka Eklund Date: Fri, 11 Feb 2022 13:57:33 +0200 Subject: branch_qt.py: Minor refactoring Limit the amount of indendations for cleaner code. Change-Id: Ifd328668c02538f1dd8fd7dde0160c82c7f23bf7 Reviewed-by: Edward Welbourne --- scripts/qt/branch_qt.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'scripts/qt/branch_qt.py') diff --git a/scripts/qt/branch_qt.py b/scripts/qt/branch_qt.py index c037d8fc..dec33615 100755 --- a/scripts/qt/branch_qt.py +++ b/scripts/qt/branch_qt.py @@ -364,21 +364,22 @@ class QtBranching: content = f.read() match = re.search(pattern, content, flags=re.MULTILINE) - if match is not None: - if match.group(1) != self.fromVersion: - log.warning( - f"--version ({self.fromVersion}) differs the one " - f"({match.group(1)}) parsed from {file}, SKIPPING" - ) - return False - log.info(f"bump {repo}:{file} from {self.fromVersion} to {self.toBranch}") - i, j = match.span(1) - with open(file, mode="w", encoding="utf-8") as f: - f.write(content[:i] + self.toBranch + content[j:]) - return True - - log.warning(f"could not read version in {repo}, {file}, SKIPPING") - return False + if match is None: + log.warning(f"could not read version in {repo}, {file}, SKIPPING") + return False + + if match.group(1) != self.fromVersion: + log.warning( + f"--version ({self.fromVersion}) differs the one ({match.group(1)}) " + f"parsed from {file}, SKIPPING" + ) + return False + + log.info(f"bump {repo}:{file} from {self.fromVersion} to {self.toBranch}") + i, j = match.span(1) + with open(file, mode="w", encoding="utf-8") as f: + f.write(content[:i] + self.toBranch + content[j:]) + return True def version_bump_repo(self, repo: git.Repo) -> None: repo_name = get_repo_name(repo) -- cgit v1.2.3