From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (unknown [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2FF111381FA for ; Fri, 16 May 2014 00:57:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 78B40E0944; Fri, 16 May 2014 00:57:26 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EBE89E0944 for ; Fri, 16 May 2014 00:57:25 +0000 (UTC) Received: from spoonbill.gentoo.org (unknown [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DDE26340060 for ; Fri, 16 May 2014 00:57:24 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 6959E1818D for ; Fri, 16 May 2014 00:57:23 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1400201790.83c2ce4a98f6fa0d86e4109203e616fdec796bed.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/api.py layman/argsparser.py layman/cli.py layman/db.py layman/dbbase.py layman/makeconf.py X-VCS-Directories: layman/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 83c2ce4a98f6fa0d86e4109203e616fdec796bed X-VCS-Branch: gsoc2014 Date: Fri, 16 May 2014 00:57:23 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 049dc75a-6496-458c-8edd-ad5e1358dcd6 X-Archives-Hash: 8520ce9017b06270f9bc04471dbb88f3 commit: 83c2ce4a98f6fa0d86e4109203e616fdec796bed Author: Devan Franchini gentoo org> AuthorDate: Fri May 16 00:56:30 2014 +0000 Commit: Devan Franchini gentoo org> CommitDate: Fri May 16 00:56:30 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=83c2ce4a layman/*.py: Removes unnecessary lists To give a minimal increase in performance some lists declarations have been removed. --- layman/api.py | 2 +- layman/argsparser.py | 12 ++++++------ layman/cli.py | 8 ++++---- layman/db.py | 6 +++--- layman/dbbase.py | 8 ++++---- layman/makeconf.py | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/layman/api.py b/layman/api.py index 763050d..4f4240c 100755 --- a/layman/api.py +++ b/layman/api.py @@ -534,7 +534,7 @@ class LaymanAPI(object): def supported_types(self): """returns a dictionary of all repository types, with boolean values""" - cmds = [x for x in list(self.config.keys()) if '_command' in x] + cmds = [x for x in self.config.keys() if '_command' in x] supported = {} for cmd in cmds: type_key = cmd.split('_')[0] diff --git a/layman/argsparser.py b/layman/argsparser.py index 5b94530..2daf3a2 100644 --- a/layman/argsparser.py +++ b/layman/argsparser.py @@ -310,7 +310,7 @@ class ArgsParser(BareConfig): if key == 'overlays': overlays = '' - if (key in list(self.options.keys()) + if (key in self.options.keys() and not self.options[key] is None): overlays = '\n'.join(self.options[key]) if self.config.has_option('MAIN', 'overlays'): @@ -320,7 +320,7 @@ class ArgsParser(BareConfig): self.output.debug('ARGSPARSER: Retrieving options option: %s' % key, 9) - if (key in list(self.options.keys()) + if (key in self.options.keys() and not self.options[key] is False): return self.options[key] @@ -333,10 +333,10 @@ class ArgsParser(BareConfig): self.output.debug('ARGSPARSER: Retrieving option: %s' % key, 9) - if key in list(self._options.keys()): + if key in self._options.keys(): return self._options[key] - if key in list(self.defaults.keys()): + if key in self.defaults.keys(): return self.defaults[key] self.output.debug('ARGSPARSER: Retrieving option failed. returning None', 9) @@ -349,7 +349,7 @@ class ArgsParser(BareConfig): self.output.debug('ARGSPARSER: Retrieving keys', 9) - keys = [i for i in list(self.options) + keys = [i for i in self.options if not self.options[i] is False and not self.options[i] is None] @@ -360,7 +360,7 @@ class ArgsParser(BareConfig): self.output.debug('ARGSPARSER: Retrieving keys 3', 9) - keys += [i for i in list(self.defaults.keys()) + keys += [i for i in self.defaults.keys() if not i in keys] self.output.debug('ARGSPARSER: Returning keys', 9) diff --git a/layman/cli.py b/layman/cli.py index 460114a..424b053 100644 --- a/layman/cli.py +++ b/layman/cli.py @@ -160,11 +160,11 @@ class Main(object): updater.print_instructions() # Make fetching the overlay list a default action - if not 'nofetch' in list(self.config.keys()): + if not 'nofetch' in self.config.keys(): # Actions that implicitely call the fetch operation before fetch_actions = ['sync', 'sync_all', 'list'] for i in fetch_actions: - if i in list(self.config.keys()): + if i in self.config.keys(): # Implicitely call fetch, break loop self.Fetch() break @@ -183,13 +183,13 @@ class Main(object): action_errors = [] results = [] act=set([x[0] for x in self.actions]) - k=set([x for x in list(self.config.keys())]) + k=set([x for x in self.config.keys()]) a=act.intersection(k) self.output.debug('Actions = %s' % str(a), 4) for action in self.actions: self.output.debug('Checking for action %s' % action[0], 4) - if action[0] in list(self.config.keys()): + if action[0] in self.config.keys(): result += getattr(self, action[1])() _errors = self.api.get_errors() if _errors: diff --git a/layman/db.py b/layman/db.py index 6a8d5ed..ce03e13 100644 --- a/layman/db.py +++ b/layman/db.py @@ -124,10 +124,10 @@ class DB(DbBase): >>> shutil.rmtree(tmpdir) ''' - if overlay.name not in list(self.overlays.keys()): + if overlay.name not in self.overlays.keys(): result = overlay.add(self.config['storage']) if result == 0: - if 'priority' in list(self.config.keys()): + if 'priority' in self.config.keys(): overlay.set_priority(self.config['priority']) self.overlays[overlay.name] = overlay self.write(self.path) @@ -213,7 +213,7 @@ class DB(DbBase): >>> shutil.rmtree(tmpdir) ''' - if overlay.name in list(self.overlays.keys()): + if overlay.name in self.overlays.keys(): make_conf = MakeConf(self.config, self.overlays) overlay.delete(self.config['storage']) del self.overlays[overlay.name] diff --git a/layman/dbbase.py b/layman/dbbase.py index 1cbf0bb..ed93daa 100644 --- a/layman/dbbase.py +++ b/layman/dbbase.py @@ -229,7 +229,7 @@ class DbBase(object): ''' tree = ET.Element('repositories', version="1.0", encoding="unicode") - tree[:] = [e.to_xml() for e in list(self.overlays.values())] + tree[:] = [e.to_xml() for e in self.overlays.values()] indent(tree) tree = ET.ElementTree(tree) try: @@ -253,11 +253,11 @@ class DbBase(object): ['rsync://gunnarwrobel.de/wrobel-stable'] ''' self.output.debug("DbBase.select(), overlay = %s" % overlay, 5) - if not overlay in list(self.overlays.keys()): + if not overlay in self.overlays.keys(): self.output.debug("DbBase.select(), unknown overlay = %s" % overlay, 4) self.output.debug("DbBase.select(), known overlays = %s" - % ', '.join(list(self.overlays.keys())), 4) + % ', '.join(self.overlays.keys()), 4) raise UnknownOverlayException(overlay) return self.overlays[overlay] @@ -300,7 +300,7 @@ class DbBase(object): ''' result = [] - selection = [overlay for (a, overlay) in list(self.overlays.items())] + selection = [overlay for (a, overlay) in self.overlays.items()] if repos is not None: selection = [overlay for overlay in selection if overlay.name in repos] diff --git a/layman/makeconf.py b/layman/makeconf.py index d8f0015..a0067c8 100644 --- a/layman/makeconf.py +++ b/layman/makeconf.py @@ -190,7 +190,7 @@ class MakeConf: for i in overlays: if i[:len(self.storage)] == self.storage: oname = os.path.basename(i) - if oname in list(self.db.keys()): + if oname in self.db.keys(): self.overlays.append(self.db[oname]) else: # These are additional overlays that we dont know