commit: 2b389e654714c99232a199d008faf9288fa3ccc9 Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org> AuthorDate: Fri May 16 00:56:30 2014 +0000 Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org> CommitDate: Fri May 16 01:06:46 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2b389e65
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 7dd5ea7..f151cbb 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