commit:     2eee92a7ba3a6d1a13d29abb6ff7c57aa30bed6a
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 18:39:45 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 18:39:45 2014 +0000
URL:        
http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2eee92a7

layman/*.py: converts keys() to lists

For py2/py3 compatibility variables such as self.overlays.keys()
or self.overlays.items() need to be implicitly converted into lists.

---
 layman/api.py        |  2 +-
 layman/argsparser.py | 12 ++++++------
 layman/cli.py        | 10 +++++-----
 layman/db.py         |  6 +++---
 layman/dbbase.py     | 10 +++++-----
 layman/makeconf.py   |  2 +-
 6 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index cbf3f76..f36be0a 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 self.config.keys() if '_command' in x]
+        cmds = [x for x in list(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 3e3d6f6..dd1cc85 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -307,7 +307,7 @@ class ArgsParser(BareConfig):
 
         if key == 'overlays':
             overlays = ''
-            if (key in self.options.__dict__.keys()
+            if (key in list(self.options.__dict__.keys())
                 and not self.options.__dict__[key] is None):
                 overlays = '\n'.join(self.options.__dict__[key])
             if self.config.has_option('MAIN', 'overlays'):
@@ -317,7 +317,7 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving options option: %s' % key, 9)
 
-        if (key in self.options.__dict__.keys()
+        if (key in list(self.options.__dict__.keys())
             and not self.options.__dict__[key] is None):
             return self.options.__dict__[key]
 
@@ -330,10 +330,10 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving option: %s' % key, 9)
 
-        if key in self._options.keys():
+        if key in list(self._options.keys()):
             return self._options[key]
 
-        if key in self.defaults.keys():
+        if key in list(self.defaults.keys()):
             return self.defaults[key]
 
         self.output.debug('ARGSPARSER: Retrieving option failed. returning 
None', 9)
@@ -346,7 +346,7 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving keys', 9)
 
-        keys = [i for i in self.options.__dict__.keys()
+        keys = [i for i in list(self.options.__dict__.keys())
                 if not self.options.__dict__[i] is None]
 
         self.output.debug('ARGSPARSER: Retrieving keys 2', 9)
@@ -356,7 +356,7 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving keys 3', 9)
 
-        keys += [i for i in self.defaults.keys()
+        keys += [i for i in list(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 258e3b9..cccddc6 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -146,7 +146,7 @@ class Main(object):
 
     def __call__(self):
         self.output.debug("CLI.__call__(): self.config.keys()"
-            " %s" % str(self.config.keys()), 6)
+            " %s" % str(list(self.config.keys())), 6)
         # blank newline  -- no " *"
         self.output.notice('')
 
@@ -157,11 +157,11 @@ class Main(object):
             updater.print_instructions()
 
         # Make fetching the overlay list a default action
-        if not 'nofetch' in self.config.keys():
+        if not 'nofetch' in list(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 self.config.keys():
+                if i in list(self.config.keys()):
                     # Implicitely call fetch, break loop
                     self.Fetch()
                     break
@@ -180,14 +180,14 @@ class Main(object):
         action_errors = []
         results = []
         act=set([x[0] for x in self.actions])
-        k=set([x for x in self.config.keys()])
+        k=set([x for x in list(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 self.config.keys():
+            if action[0] in list(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 ce03e13..6a8d5ed 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -124,10 +124,10 @@ class DB(DbBase):
         >>> shutil.rmtree(tmpdir)
         '''
 
-        if overlay.name not in self.overlays.keys():
+        if overlay.name not in list(self.overlays.keys()):
             result = overlay.add(self.config['storage'])
             if result == 0:
-                if 'priority' in self.config.keys():
+                if 'priority' in list(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 self.overlays.keys():
+        if overlay.name in list(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 8fa3ba8..ff99965 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -107,7 +107,7 @@ class DbBase(object):
 
 
     def __eq__(self, other):
-        for key in set(self.overlays.keys() + other.overlays.keys()):
+        for key in set(list(self.overlays.keys()) + 
list(other.overlays.keys())):
             if self.overlays[key] != other.overlays[key]:
                 return False
         return True
@@ -221,7 +221,7 @@ class DbBase(object):
         '''
 
         tree = ET.Element('repositories', version="1.0")
-        tree[:] = [e.to_xml() for e in self.overlays.values()]
+        tree[:] = [e.to_xml() for e in list(self.overlays.values())]
         indent(tree)
         tree = ET.ElementTree(tree)
         try:
@@ -248,11 +248,11 @@ class DbBase(object):
         ['rsync://gunnarwrobel.de/wrobel-stable']
         '''
         self.output.debug("DbBase.select(), overlay = %s" % overlay, 5)
-        if not overlay in self.overlays.keys():
+        if not overlay in list(self.overlays.keys()):
             self.output.debug("DbBase.select(), unknown overlay = %s"
                 % overlay, 4)
             self.output.debug("DbBase.select(), known overlays = %s"
-                % ', '.join(self.overlays.keys()), 4)
+                % ', '.join(list(self.overlays.keys())), 4)
             raise UnknownOverlayException(overlay)
         return self.overlays[overlay]
 
@@ -295,7 +295,7 @@ class DbBase(object):
         '''
         result = []
 
-        selection = [overlay for (a, overlay) in self.overlays.items()]
+        selection = [overlay for (a, overlay) in list(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 52762a2..b592fc0 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -189,7 +189,7 @@ class MakeConf:
             for i in overlays:
                 if i[:len(self.storage)] == self.storage:
                     oname = os.path.basename(i)
-                    if  oname in self.db.keys():
+                    if  oname in list(self.db.keys()):
                         self.overlays.append(self.db[oname])
                     else:
                         # These are additional overlays that we dont know

Reply via email to