From b3b3383a0dd9e12d6c6d9e2e5181c2a67fc7664f Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 29 May 2011 16:33:19 +0100 Subject: [PATCH] Ran idioms filter on code --- tests/server.py | 2 +- tests/testmanifest.py | 3 +-- tests/testselections.py | 3 +-- zeroinstall/0launch-gui/impl_list.py | 3 +-- zeroinstall/injector/iface_cache.py | 2 +- zeroinstall/injector/writer.py | 3 +-- zeroinstall/zerostore/manifest.py | 6 ++---- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/server.py b/tests/server.py index 4ade95a..a1f5500 100644 --- a/tests/server.py +++ b/tests/server.py @@ -60,7 +60,7 @@ def handle_requests(*script): print("Waiting for request") global next_step for next_step in script: - if type(next_step) != tuple: next_step = (next_step,) + if not isinstance(next_step, tuple): next_step = (next_step,) for x in next_step: httpd.handle_request() print("Done") diff --git a/tests/testmanifest.py b/tests/testmanifest.py index 8779c1b..61fcfc9 100755 --- a/tests/testmanifest.py +++ b/tests/testmanifest.py @@ -108,8 +108,7 @@ class TestManifest(BaseTest): 'X 8a1f3c5f416f0e63140928102c44cd16ec2c6100 1172429666 5816 install.sh\n' 'D /0install\n' 'S 2b37e4457a1a38cfab89391ce1bfbe4dc5473fc3 26 mime-application:x-java-archive.png\n') - keys = parsed.keys() - keys.sort() + keys = sorted(parsed.keys()) assert keys == ['0install', '0install/mime-application:x-java-archive.png', 'README', 'install.sh'] for bad in ['Hello', 'D bob\n', 'D /bob\nD /bob\n']: try: diff --git a/tests/testselections.py b/tests/testselections.py index c2d2478..14a7629 100755 --- a/tests/testselections.py +++ b/tests/testselections.py @@ -27,8 +27,7 @@ class TestSelections(BaseTest): self.assertEquals('http://foo/Source.xml', s.interface) self.assertEquals(2, len(s.selections)) - sels = [(sel.interface, sel) for sel in s.selections.values()] - sels.sort() + sels = sorted([(sel.interface, sel) for sel in s.selections.values()]) sels = [sel for uri,sel in sels] self.assertEquals('http://foo/Compiler.xml', sels[0].interface) diff --git a/zeroinstall/0launch-gui/impl_list.py b/zeroinstall/0launch-gui/impl_list.py index 5f8817f..d1d5fe1 100644 --- a/zeroinstall/0launch-gui/impl_list.py +++ b/zeroinstall/0launch-gui/impl_list.py @@ -11,8 +11,7 @@ def _build_stability_menu(policy, impl): menu = gtk.Menu() upstream = impl.upstream_stability or model.testing - choices = model.stability_levels.values() - choices.sort() + choices = sorted(model.stability_levels.values()) choices.reverse() def set(new): diff --git a/zeroinstall/injector/iface_cache.py b/zeroinstall/injector/iface_cache.py index 211b940..83b5368 100644 --- a/zeroinstall/injector/iface_cache.py +++ b/zeroinstall/injector/iface_cache.py @@ -364,7 +364,7 @@ class IfaceCache(object): @param uri: the URI of the interface to find @rtype: L{model.Interface} """ - if type(uri) == str: + if isinstance(uri, str): uri = unicode(uri) assert isinstance(uri, unicode) diff --git a/zeroinstall/injector/writer.py b/zeroinstall/injector/writer.py index 5d62dd0..00c7c07 100644 --- a/zeroinstall/injector/writer.py +++ b/zeroinstall/injector/writer.py @@ -39,8 +39,7 @@ def save_feed(feed): if feed.last_checked: root.setAttribute('last-checked', str(feed.last_checked)) - impls = feed.implementations.values() - impls.sort() + impls = sorted(feed.implementations.values()) for impl in impls: if impl.user_stability: node = doc.createElementNS(XMLNS_IFACE, 'implementation') diff --git a/zeroinstall/zerostore/manifest.py b/zeroinstall/zerostore/manifest.py index d23afdf..afd0764 100644 --- a/zeroinstall/zerostore/manifest.py +++ b/zeroinstall/zerostore/manifest.py @@ -80,8 +80,7 @@ class OldSHA1(Algorithm): if stat.S_ISDIR(m): if sub != '/': yield "D %s %s" % (int(info.st_mtime), sub) - items = os.listdir(full) - items.sort() + items = sorted(os.listdir(full)) subdir = sub if not subdir.endswith('/'): subdir += '/' @@ -448,8 +447,7 @@ class HashLibAlgorithm(Algorithm): if not stat.S_ISDIR(m): raise Exception(_('Not a directory: "%s"') % full) if sub != '/': yield "D %s" % sub - items = os.listdir(full) - items.sort() + items = sorted(os.listdir(full)) dirs = [] for leaf in items: path = os.path.join(root, sub[1:], leaf) -- 2.11.4.GIT