[libvirt-ci PATCH 02/13] lcitool: Decrease the indent when creating a tempdir for initrd injection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The 'with' statement doesn't define a new code block [1], thus no local
namespace is created. Therefore, we can still access the @content
variable outside of the 'with' block. So, there's really no need to
hold the @initrd_template file open longer than necessary (not that it
would be a big deal anyway).

[1] https://docs.python.org/3.7/reference/executionmodel.html

Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx>
---
 guests/lcitool | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index dfb1ebc..9a9326d 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -608,11 +608,11 @@ class Application:
                         facts[option]
                     )
 
-                tempdir = tempfile.mkdtemp()
-                initrd_inject = os.path.join(tempdir, install_config)
+            tempdir = tempfile.mkdtemp()
+            initrd_inject = os.path.join(tempdir, install_config)
 
-                with open(initrd_inject, "w") as inject:
-                    inject.write(content)
+            with open(initrd_inject, "w") as inject:
+                inject.write(content)
 
             # preseed files must use a well-known name to be picked up by
             # d-i; for kickstart files, we can use whatever name we please
-- 
2.25.3





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux