[libvirt] [jenkins-ci PATCH v3 08/10] lcitool: refactor logic for building package list

Daniel P. Berrangé posted 10 patches 6 years, 11 months ago
There is a newer version of this series
[libvirt] [jenkins-ci PATCH v3 08/10] lcitool: refactor logic for building package list
Posted by Daniel P. Berrangé 6 years, 11 months ago
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 guests/lcitool | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 1271954..0978c40 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -529,15 +529,18 @@ class Application:
                 if os_full in mappings[package]:
                     temp[package] = mappings[package][os_full]
 
-        flattened = []
+        pkgs = []
         for item in temp:
-            if temp[item] is not None and temp[item] not in flattened:
-                flattened += [temp[item]]
+            pkgname = temp[item]
+            if pkgname is None:
+                continue
+            if pkgname not in pkgs:
+                pkgs.append(pkgname)
 
         print("FROM {}".format(facts["docker_base"]))
 
         sys.stdout.write("ENV PACKAGES ")
-        sys.stdout.write(" \\\n             ".join(sorted(flattened)))
+        sys.stdout.write(" \\\n             ".join(sorted(pkgs)))
 
         if package_format == "deb":
             sys.stdout.write(textwrap.dedent("""
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH v3 08/10] lcitool: refactor logic for building package list
Posted by Andrea Bolognani 6 years, 11 months ago
On Wed, 2019-02-13 at 19:03 +0000, Daniel P. Berrangé wrote:
[...]
> +            pkgname = temp[item]
> +            if pkgname is None:
> +                continue
> +            if pkgname not in pkgs:
> +                pkgs.append(pkgname)

I think this would look slightly better as

  if pkgname is None:
      continue
  if pkgname in pkgs:
      continue
  pkgs.append(pkgname)

Regardless of whether you change it or keep it as-is,

  Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list