[python-debian/master 16/36] Use list comprehensions instead of map where a list is required. In Python 3, map returns an iterator, not a list.
Colin Watson
cjwatson at canonical.com
Mon Oct 8 07:41:22 UTC 2012
---
lib/debian/deb822.py | 2 +-
tests/test_changelog.py | 2 +-
tests/test_debfile.py | 9 ++++-----
tests/test_debian_support.py | 2 +-
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/lib/debian/deb822.py b/lib/debian/deb822.py
index b45a269..0761c6e 100644
--- a/lib/debian/deb822.py
+++ b/lib/debian/deb822.py
@@ -855,7 +855,7 @@ class PkgRelation(object):
tl_deps = cls.__comma_sep_RE.split(raw.strip()) # top-level deps
cnf = map(cls.__pipe_sep_RE.split, tl_deps)
- return map(lambda or_deps: map(parse_rel, or_deps), cnf)
+ return [[parse_rel(or_dep) for or_dep in or_deps] for or_deps in cnf]
@staticmethod
def str(rels):
diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index 17353c9..2ba0676 100755
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -230,7 +230,7 @@ haskell-src-exts (1.8.2-2) unstable; urgency=low
f = open('test_changelog')
c = changelog.Changelog(f)
f.close()
- self.assertEqual(map(str, c._blocks), map(str, c))
+ self.assertEqual([str(b) for b in c._blocks], [str(b) for b in c])
def test_len(self):
f = open('test_changelog')
diff --git a/tests/test_debfile.py b/tests/test_debfile.py
index 96fff89..c9287cc 100755
--- a/tests/test_debfile.py
+++ b/tests/test_debfile.py
@@ -144,11 +144,10 @@ class TestDebFile(unittest.TestCase):
def test_data_names(self):
""" test for file list equality """
tgz = self.d.data.tgz()
- dpkg_names = map(os.path.normpath,
- [ x.strip() for x in
- os.popen("dpkg-deb --fsys-tarfile %s | tar t" %
- self.debname).readlines() ])
- debfile_names = map(os.path.normpath, tgz.getnames())
+ with os.popen("dpkg-deb --fsys-tarfile %s | tar t" %
+ self.debname) as tar:
+ dpkg_names = [os.path.normpath(x.strip()) for x in tar.readlines()]
+ debfile_names = [os.path.normpath(name) for name in tgz.getnames()]
# skip the root
self.assertEqual(debfile_names[1:], dpkg_names[1:])
diff --git a/tests/test_debian_support.py b/tests/test_debian_support.py
index 20cafff..e154588 100755
--- a/tests/test_debian_support.py
+++ b/tests/test_debian_support.py
@@ -189,7 +189,7 @@ class HelperRoutineTests(unittest.TestCase):
'14293c9bd646a15dc656eaf8fba95124020dfada')
def test_patch_lines(self):
- file_a = map(lambda x: "%d\n" % x, range(1, 18))
+ file_a = ["%d\n" % x for x in range(1, 18)]
file_b = ['0\n', '1\n', '<2>\n', '<3>\n', '4\n', '5\n', '7\n', '8\n',
'11\n', '12\n', '<13>\n', '14\n', '15\n', 'A\n', 'B\n',
'C\n', '16\n', '17\n',]
--
1.7.2.5
More information about the pkg-python-debian-commits
mailing list