[Blends-commit] [SCM] website branch, master, updated. a4a1935750ff73446217913e7f622f1d2cc0d135

Ole Streicher olebole at debian.org
Wed Apr 27 11:19:50 UTC 2016


The following commit has been merged in the master branch:
commit 1dad6454ca8a35ceccd11b63acc32db887ed70f5
Author: Ole Streicher <olebole at debian.org>
Date:   Wed Apr 27 10:12:28 2016 +0200

    Make dep_strength_keys and pkgstatus_sortedkeys more pythonic

diff --git a/webtools/blendstasktools.py b/webtools/blendstasktools.py
index d75013c..148e0f4 100644
--- a/webtools/blendstasktools.py
+++ b/webtools/blendstasktools.py
@@ -180,20 +180,11 @@ pkgstatus = {
     },
 }
 
-# http://wiki.python.org/moin/HowTo/Sorting#Sortingbykeys
-_tmplist = []
-for key in pkgstatus.keys():
-    _tmplist.append((key, pkgstatus[key]['order']))
-_tmpsorted = sorted(_tmplist, key=lambda x: (x[1], x[0]))
-pkgstatus_sortedkeys = []
-for _tmp in _tmpsorted:
-    pkgstatus_sortedkeys.append(_tmp[0])
-
-dep_strength_keys = []
-for pkgstat in pkgstatus:
-    for dep in pkgstatus[pkgstat]['dependencies']:
-        if dep not in dep_strength_keys:
-            dep_strength_keys.append(dep)
+pkgstatus_sortedkeys = sorted(pkgstatus.keys(),
+                              key=lambda x: (pkgstatus[x]['order'], x))
+
+dep_strength_keys = set(itertools.chain(*(pkgstatus[pkgstat]['dependencies']
+                                          for pkgstat in pkgstatus)))
 
 rmpub = codecs.open('remove-publications-from-tasks-files.dat', 'w+', 'utf-8')
 
diff --git a/webtools/blendstasktools_udd.py b/webtools/blendstasktools_udd.py
index 8299262..60958e6 100644
--- a/webtools/blendstasktools_udd.py
+++ b/webtools/blendstasktools_udd.py
@@ -176,20 +176,11 @@ pkgstatus = {
     },
 }
 
-# http://wiki.python.org/moin/HowTo/Sorting#Sortingbykeys
-_tmplist = []
-for key in pkgstatus.keys():
-    _tmplist.append((key, pkgstatus[key]['order']))
-_tmpsorted = sorted(_tmplist, key=lambda x: (x[1], x[0]))
-pkgstatus_sortedkeys = []
-for _tmp in _tmpsorted:
-    pkgstatus_sortedkeys.append(_tmp[0])
-
-dep_strength_keys = []
-for pkgstat in pkgstatus:
-    for dep in pkgstatus[pkgstat]['dependencies']:
-        if dep not in dep_strength_keys:
-            dep_strength_keys.append(dep)
+pkgstatus_sortedkeys = sorted(pkgstatus.keys(),
+                              key=lambda x: (pkgstatus[x]['order'], x))
+
+dep_strength_keys = set(itertools.chain(*(pkgstatus[pkgstat]['dependencies']
+                                          for pkgstat in pkgstatus)))
 
 rmpub = codecs.open('remove-publications-from-tasks-files.dat', 'w+', 'utf-8')
 

-- 
Static and dynamic websites for Debian Pure Blends



More information about the Blends-commit mailing list