[devscripts] 01/04: wrap-and-sort: Use list comprehension instead of filter

Benjamin Drung bdrung at moszumanska.debian.org
Tue Jan 12 23:12:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

bdrung pushed a commit to branch master
in repository devscripts.

commit 00155fed2f035a230eeebb201cafed4debf5f5c8
Author: Benjamin Drung <bdrung at debian.org>
Date:   Tue Jan 12 23:33:26 2016 +0100

    wrap-and-sort: Use list comprehension instead of filter
    
    A list comprehension is easier to read than a filter function (and it
    is shorter).
    
    Signed-off-by: Benjamin Drung <bdrung at debian.org>
---
 scripts/wrap-and-sort | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/wrap-and-sort b/scripts/wrap-and-sort
index 98a4bb5..f9e6e0e 100755
--- a/scripts/wrap-and-sort
+++ b/scripts/wrap-and-sort
@@ -1,6 +1,6 @@
 #!/usr/bin/python3
 #
-# Copyright (C) 2010-2014, Benjamin Drung <bdrung at debian.org>
+# Copyright (C) 2010-2016, Benjamin Drung <bdrung at debian.org>
 #               2010, Stefano Rivera <stefanor at ubuntu.com>
 #
 # Permission to use, copy, modify, and/or distribute this software for any
@@ -94,7 +94,7 @@ class WrapAndSortControl(Control):
                     trailing_comma, sort=True):
         # An empty element is not explicitly disallowed by Policy but known to
         # break QA tools, so remove any
-        packages = list(filter(None, [x.strip() for x in control[entry].split(",")]))
+        packages = [x.strip() for x in control[entry].split(",") if x.strip()]
 
         # Sanitize alternative packages. E.g. "a|b  |c" -> "a | b | c"
         packages = [" | ".join([x.strip() for x in p.split("|")]) for p in packages]
@@ -130,7 +130,7 @@ class Install(object):
     def open(self, filename):
         assert os.path.isfile(filename), "%s does not exist." % (filename)
         self.filename = filename
-        self.content = list(filter(None, [l.strip() for l in open(filename).readlines()]))
+        self.content = [l.strip() for l in open(filename).readlines() if l.strip()]
 
     def save(self, filename=None):
         if filename:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list