commit:     8469e061997ef1add4b6d4e1e7804111638af8b2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  9 16:44:20 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jan  9 16:44:20 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=8469e061

gpkg: hoist level of indentation up

Early-return instead of a huge block inside of `if not x: ...`.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/gpkg.py | 51 +++++++++++++++++++++++++--------------------------
 1 file changed, 25 insertions(+), 26 deletions(-)

diff --git a/lib/portage/gpkg.py b/lib/portage/gpkg.py
index cc36a66d62..41ec921e32 100644
--- a/lib/portage/gpkg.py
+++ b/lib/portage/gpkg.py
@@ -630,39 +630,38 @@ class checksum_helper:
         """
         Tell GnuPG that the file is EOF, then get results, then cleanup.
         """
-        if self.finished:
+        if self.finished or self.gpg_proc is None:
             return
 
-        if self.gpg_proc is not None:
-            # Tell GnuPG EOF
-            self.gpg_proc.stdin.close()
+        # Tell GnuPG EOF
+        self.gpg_proc.stdin.close()
 
-            return_code = self.gpg_proc.wait()
+        return_code = self.gpg_proc.wait()
 
-            if self.sign_file_path:
-                os.remove(self.sign_file_path)
+        if self.sign_file_path:
+            os.remove(self.sign_file_path)
 
-            self.finished = True
+        self.finished = True
 
-            self.gpg_result = self.gpg_proc.stderr.read()
-            self.gpg_output = self.gpg_proc.stdout.read()
-            self.gpg_proc.stdout.close()
-            self.gpg_proc.stderr.close()
+        self.gpg_result = self.gpg_proc.stderr.read()
+        self.gpg_output = self.gpg_proc.stdout.read()
+        self.gpg_proc.stdout.close()
+        self.gpg_proc.stderr.close()
 
-            if return_code == os.EX_OK:
-                if self.gpg_operation == checksum_helper.VERIFY:
-                    self._check_gpg_status(self.gpg_result)
-            else:
-                gpg_error_lines = self.gpg_result.decode(
-                    "UTF-8", errors="replace"
-                ).splitlines()
-
-                if self.gpg_operation == checksum_helper.SIGNING:
-                    self.show_gpg_error(checksum_helper.SIGNING, 
gpg_error_lines)
-                    raise GPGException("GnuPG signing failed")
-                elif self.gpg_operation == checksum_helper.VERIFY:
-                    self.show_gpg_error(checksum_helper.VERIFY, 
gpg_error_lines)
-                    raise InvalidSignature("GnuPG verification failed")
+        if return_code == os.EX_OK:
+            if self.gpg_operation == checksum_helper.VERIFY:
+                self._check_gpg_status(self.gpg_result)
+        else:
+            gpg_error_lines = self.gpg_result.decode(
+                "UTF-8", errors="replace"
+            ).splitlines()
+
+            if self.gpg_operation == checksum_helper.SIGNING:
+                self.show_gpg_error(checksum_helper.SIGNING, gpg_error_lines)
+                raise GPGException("GnuPG signing failed")
+            elif self.gpg_operation == checksum_helper.VERIFY:
+                self.show_gpg_error(checksum_helper.VERIFY, gpg_error_lines)
+                raise InvalidSignature("GnuPG verification failed")
 
 
 class tar_safe_extract:

Reply via email to