public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-07 22:21 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-07 22:21 UTC (permalink / raw
  To: gentoo-commits

commit:     c7e10325007dd6b86196f61ddb7a5adc3797127b
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May  7 22:17:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May  7 22:21:05 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c7e10325

layman/{config, constants, output}.py: Adds notice level.

The -q flag setting was being ignored by output.notice() calls.
Adding note_level to the output.notice() function makes it so
that the output will be quieted, if desired.

X-Gentoo-Bug: 457726
X-Gentoo-Bug-URL: https://bugs.gentoo.org/457726

---
 layman/config.py    |  1 +
 layman/constants.py |  1 +
 layman/output.py    | 19 ++++++++++++++++---
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 576ed05..bf33f50 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -228,6 +228,7 @@ class BareConfig(object):
     def _set_quietness(self, value):
             self._options['output'].set_info_level(value)
             self._options['output'].set_warn_level(value)
+            self._options['output'].set_note_level(value)
 
     def __getitem__(self, key):
         return self._get_(key)

diff --git a/layman/constants.py b/layman/constants.py
index 6f53de3..9a2af40 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -48,6 +48,7 @@ NOT_SUPPORTED_MSG = '*** You are lacking the necessary tools' +\
 OFF = 0
 WARN_LEVEL = 4
 INFO_LEVEL = 4
+NOTE_LEVEL = 4
 DEBUG_LEVEL = 4
 DEBUG_VERBOSITY = 2
 

diff --git a/layman/output.py b/layman/output.py
index b48531a..48b44a1 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -12,7 +12,7 @@ __version__ = "0.1"
 
 import sys
 
-from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL, OFF
+from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, NOTE_LEVEL, DEBUG_LEVEL, OFF
 from layman.compatibility import encode
 
 
@@ -25,6 +25,7 @@ class MessageBase(object):
                  err = sys.stderr,
                  info_level = INFO_LEVEL,
                  warn_level = WARN_LEVEL,
+                 note_level = NOTE_LEVEL,
                  col = True,
                  error_callback=None
                  ):
@@ -46,6 +47,9 @@ class MessageBase(object):
         # The higher the level the more information you will get
         self.info_lev = info_level
 
+        # The higher the level the more information you will get
+        self.note_lev = note_level
+
         # Should the output be colored?
         self.color_func = None
         self.set_colorize(col)
@@ -81,6 +85,10 @@ class MessageBase(object):
         self.warn_lev = warn_level
 
 
+    def set_note_level(self, note_level = NOTE_LEVEL):
+        self.note_lev = note_level
+
+
     def set_debug_level(self, debugging_level = DEBUG_LEVEL):
         self.debug_lev = debugging_level
 
@@ -103,12 +111,13 @@ class Message(MessageBase):
                  err = sys.stderr,
                  info_level = INFO_LEVEL,
                  warn_level = WARN_LEVEL,
+                 note_level = NOTE_LEVEL,
                  col = True,
                  error_callback = None
                 ):
 
         MessageBase.__init__(self, out, err, info_level, warn_level,
-            col, error_callback)
+            note_level, col, error_callback)
 
 
     ## Output Functions
@@ -127,7 +136,11 @@ class Message(MessageBase):
             print  >> self.std_out, self.color_func('yellow', 'DEBUG: ') + i
 
 
-    def notice (self, note):
+    def notice (self, note, level = NOTE_LEVEL):
+
+        if level > self.note_lev:
+            return
+
         print >> self.std_out, note
 
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14  0:37 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14  0:37 UTC (permalink / raw
  To: gentoo-commits

commit:     9dff67cf63c78d7abb441de40b4d1e5c3ae7cb2d
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 00:35:07 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 00:35:07 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=9dff67cf

Changes "Exception, error" to "Exception as error".

This change has been made for py2 and py3 compatibility.

---
 layman/api.py      | 16 ++++++++--------
 layman/cli.py      |  2 +-
 layman/dbbase.py   |  4 ++--
 layman/makeconf.py |  4 ++--
 layman/remotedb.py | 10 +++++-----
 layman/updater.py  |  2 +-
 layman/utils.py    |  2 +-
 7 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 11534fd..475691b 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -113,7 +113,7 @@ class LaymanAPI(object):
             try:
                 self._get_installed_db().delete(
                     self._get_installed_db().select(ovl))
-            except Exception, e:
+            except Exception as e:
                 self._error(
                         "Exception caught disabling repository '"+ovl+
                             "':\n"+str(e))
@@ -147,7 +147,7 @@ class LaymanAPI(object):
             try:
                 success = self._get_installed_db().add(
                     self._get_remote_db().select(ovl))
-            except Exception, e:
+            except Exception as e:
                 self._error("Exception caught enabling repository '"+ovl+
                     "' : "+str(e))
             results.append(success)
@@ -201,7 +201,7 @@ class LaymanAPI(object):
                 continue
             try:
                 overlay = db.select(ovl)
-            except UnknownOverlayException, error:
+            except UnknownOverlayException as error:
                 self._error(error)
                 result[ovl] = ('', False, False)
             else:
@@ -255,7 +255,7 @@ class LaymanAPI(object):
                 overlay = db.select(ovl)
                 #print "overlay = ", ovl
                 #print "!!!", overlay
-            except UnknownOverlayException, error:
+            except UnknownOverlayException as error:
                 #print "ERRORS", str(error)
                 self._error(error)
                 result[ovl] = ('', False, False)
@@ -311,7 +311,7 @@ class LaymanAPI(object):
                 #self.output.debug("API.sync(); selecting %s, db = %s" % (ovl, str(db)), 5)
                 odb = db.select(ovl)
                 self.output.debug("API.sync(); %s now selected" %ovl, 5)
-            except UnknownOverlayException, error:
+            except UnknownOverlayException as error:
                 #self.output.debug("API.sync(); UnknownOverlayException selecting %s" %ovl, 5)
                 #self._error(str(error))
                 fatals.append((ovl,
@@ -364,7 +364,7 @@ class LaymanAPI(object):
                 self.output.debug("API.sync(); starting db.sync(ovl)", 5)
                 db.sync(ovl)
                 success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))
-            except Exception, error:
+            except Exception as error:
                 fatals.append((ovl,
                     'Failed to sync overlay "' + ovl + '".\nError was: '
                     + str(error)))
@@ -457,7 +457,7 @@ class LaymanAPI(object):
             self.output.debug(
                 'LaymanAPI.fetch_remote_list(); cache updated = %s'
                 % str(dbreload),8)
-        except Exception, error:
+        except Exception as error:
             self.output.error('Failed to fetch overlay list!\n Original Error was: '
                     + str(error))
             return False
@@ -585,7 +585,7 @@ class LaymanAPI(object):
             elif self.config['news_reporter'] == 'pkgcore':
                 # pkgcore is not yet capable
                 return
-        except Exception, err:
+        except Exception as err:
             msg = "update_news() failed running %s news reporter function\n" +\
                   "Error was; %s"
             self._error(msg % (self.config['news_reporter'], err))

diff --git a/layman/cli.py b/layman/cli.py
index a5d2799..258e3b9 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -173,7 +173,7 @@ class Main(object):
         try:
             new_umask = int(umask, 8)
             old_umask = os.umask(new_umask)
-        except Exception, error:
+        except Exception as error:
             self.output.die('Failed setting to umask "' + umask +
                 '"!\nError was: ' + str(error))
 

diff --git a/layman/dbbase.py b/layman/dbbase.py
index e5c0fd9..8d57a9f 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -124,7 +124,7 @@ class DbBase(object):
             df = fileopen(path, 'r')
             document = df.read()
 
-        except Exception, error:
+        except Exception as error:
             if not self.ignore_init_read_errors:
                 self.output.error('Failed to read the overlay list at ("'
                     + path + '")')
@@ -231,7 +231,7 @@ class DbBase(object):
 """)
             tree.write(f, encoding='utf-8')
             f.close()
-        except Exception, error:
+        except Exception as error:
             raise Exception('Failed to write to local overlays file: '
                             + path + '\nError was:\n' + str(error))
 

diff --git a/layman/makeconf.py b/layman/makeconf.py
index 9740072..1abe318 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -273,7 +273,7 @@ class MakeConf:
 
             make_conf.close()
 
-        except Exception, error:
+        except Exception as error:
             self.output.error('MakeConf: write(); Failed to write "'
                 + self.path + '".\nError was:\n' + str(error))
             return False
@@ -290,7 +290,7 @@ class MakeConf:
 
             make_conf.close()
 
-        except Exception, error:
+        except Exception as error:
             self.output.error('MakeConf: content(); Failed to read "' +
                 self.path + '".\nError was:\n' + str(error))
             raise error

diff --git a/layman/remotedb.py b/layman/remotedb.py
index 98dffbb..38d9fa8 100644
--- a/layman/remotedb.py
+++ b/layman/remotedb.py
@@ -245,7 +245,7 @@ class RemoteDB(DbBase):
         if not os.path.exists(os.path.dirname(mpath)):
             try:
                 os.makedirs(os.path.dirname(mpath))
-            except OSError, error:
+            except OSError as error:
                 raise OSError('Failed to create layman storage directory ' +
                               os.path.dirname(mpath) + '\n' +
                               'Error was:' + str(error))
@@ -290,7 +290,7 @@ class RemoteDB(DbBase):
                 self.output.info('Remote list already up to date: %s'
                     % url, 4)
                 self.output.info('Last-modified: %s' % timestamp, 4)
-        except IOError, error:
+        except IOError as error:
             self.output.error('RemoteDB._fetch_file(); Failed to update the '
                 'overlay list from: %s\nIOError was:%s\n'
                 % (url, str(error)))
@@ -333,7 +333,7 @@ class RemoteDB(DbBase):
                 verify=verify,
                 proxies=self.proxies,
                 )
-        except SSLError, error:
+        except SSLError as error:
             self.output.error('RemoteDB._fetch_url(); Failed to update the '
                 'overlay list from: %s\nSSLError was:%s\n'
                 % (url, str(error)))
@@ -388,7 +388,7 @@ class RemoteDB(DbBase):
 
         try:
             self.read(olist, origin=url)
-        except Exception, error:
+        except Exception as error:
             self.output.debug("RemoteDB._check_download(), url=%s \nolist:\n"
                 % url,2)
             self.output.debug(olist, 2)
@@ -419,7 +419,7 @@ class RemoteDB(DbBase):
 
             has_updates = True
 
-        except Exception, error:
+        except Exception as error:
             raise IOError('Failed to temporarily cache overlays list in'
                           ' ' + mpath + '\nError was:\n' + str(error))
         return has_updates

diff --git a/layman/updater.py b/layman/updater.py
index f7d91e6..7c46707 100644
--- a/layman/updater.py
+++ b/layman/updater.py
@@ -23,7 +23,7 @@ def rename_db(config, newname, output):
                 "name is...: %s" %newname, 2)
             output.notice('')
             return
-        except OSError, err:
+        except OSError as err:
             output.error("  Automatic db rename failed:\n%s" %str(err))
     else:
         output.info("  Automatic db rename, failed access to: %s"

diff --git a/layman/utils.py b/layman/utils.py
index ab9904f..f174215 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -174,7 +174,7 @@ def delete_empty_directory(mdir, output=None):
             output.info('Deleting _empty_ directory "%s"' % mdir, 2)
             try:
                 os.rmdir(mdir)
-            except OSError, error:
+            except OSError as error:
                 output.warn(str(error))
         else:
             output.warn('Insufficient permissions to delete _empty_ folder "%s".' % mdir)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14  3:21 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14  3:21 UTC (permalink / raw
  To: gentoo-commits

commit:     90cd00ecd4f314fc46e2379c569b31260f1d0e5e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 03:21:13 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 03:21:13 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=90cd00ec

dbbase.py: Adds py2/py3 compatibility to exception handling.

---
 layman/dbbase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 8d57a9f..475ce44 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -156,7 +156,7 @@ class DbBase(object):
         '''
         try:
             document = ET.fromstring(text)
-        except xml.parsers.expat.ExpatError, error:
+        except xml.parsers.expat.ExpatError as error:
             raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint())
 
         overlays = document.findall('overlay') + \


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 17:32 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 17:32 UTC (permalink / raw
  To: gentoo-commits

commit:     35ea2821a51610ad0d9563d0964ccfba3864c3d3
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 03:21:13 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 17:31:29 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=35ea2821

dbbase.py: Adds py2/py3 compatibility to exception handling.

---
 layman/dbbase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 8d57a9f..475ce44 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -156,7 +156,7 @@ class DbBase(object):
         '''
         try:
             document = ET.fromstring(text)
-        except xml.parsers.expat.ExpatError, error:
+        except xml.parsers.expat.ExpatError as error:
             raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint())
 
         overlays = document.findall('overlay') + \


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 18:44 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 18:44 UTC (permalink / raw
  To: gentoo-commits

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


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 18:55 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 18:55 UTC (permalink / raw
  To: gentoo-commits

commit:     70adaeef4a48570f7a27e845c6e4c81256a202f3
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 18:54:56 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 18:54:56 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=70adaeef

layman/{output, version}.py: Updates print() functions

---
 layman/output.py  | 16 ++++++++--------
 layman/version.py |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index 48b44a1..ea98894 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -133,7 +133,7 @@ class Message(MessageBase):
             return
 
         for i in info.split('\n'):
-            print  >> self.std_out, self.color_func('yellow', 'DEBUG: ') + i
+            print(self.color_func('yellow', 'DEBUG: ') + i, file=self.std_out)
 
 
     def notice (self, note, level = NOTE_LEVEL):
@@ -141,7 +141,7 @@ class Message(MessageBase):
         if level > self.note_lev:
             return
 
-        print >> self.std_out, note
+        print(note, file=self.std_out)
 
 
     def info (self, info, level = INFO_LEVEL):
@@ -153,7 +153,7 @@ class Message(MessageBase):
             return
 
         for i in info.split('\n'):
-            print  >> self.std_out, " %s %s" % (self.color_func('green', '*'),i)
+            print(" %s %s" % (self.color_func('green', '*'),i), file=self.std_out)
 
 
     def status (self, message, status, info = 'ignored'):
@@ -167,7 +167,7 @@ class Message(MessageBase):
             return
 
         for i in lines[0:-1]:
-            print >> self.std_out, " %s %s" % (self.color_func('green', '*'),i)
+            print(" %s %s" % (self.color_func('green', '*'),i), file=self.std_out)
 
         i = lines[-1]
 
@@ -181,8 +181,8 @@ class Message(MessageBase):
         else:
             result = '[' + self.color_func('yellow', info) + ']'
 
-        print >> " %s %s %s %S" % (self.color_func('green', '*'), i,
-            ('.' * (58 - len(i))), result)
+        print(file=" %s %s %s %S" % (self.color_func('green', '*'), i,
+            ('.' * (58 - len(i))), result))
 
 
     def warn (self, warn, level = WARN_LEVEL):
@@ -194,7 +194,7 @@ class Message(MessageBase):
             return
 
         for i in warn.split('\n'):
-            print >> self.std_out, " %s %s" % (self.color_func('yellow', '*'),i)
+            print(" %s %s" % (self.color_func('yellow', '*'),i), file=self.std_out)
 
 
     def error (self, error):
@@ -208,7 +208,7 @@ class Message(MessageBase):
             # "layman -L |& less".
             self.std_out.flush()
             self.error_out.flush()
-            print >> self.std_out, " %s %s" % (self.color_func('red', '*'), i)
+            print(" %s %s" % (self.color_func('red', '*'), i), file=self.std_out)
             self.std_out.flush()
         self.do_error_callback(error)
 

diff --git a/layman/version.py b/layman/version.py
index 90c7412..276ee86 100644
--- a/layman/version.py
+++ b/layman/version.py
@@ -25,4 +25,4 @@ __version__ = "$Id: version.py 309 2007-04-09 16:23:38Z wrobel $"
 VERSION = '2.0.0-git'
 
 if __name__ == '__main__':
-    print VERSION
+    print(VERSION)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 19:29 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 19:29 UTC (permalink / raw
  To: gentoo-commits

commit:     925b90c710c2376b233d681e969418434f01cb59
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 19:24:59 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 19:24:59 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=925b90c7

layman/api.py: Corrects output of repos and stderr.

Due to repos coming in as a binary string, it needed to be converted
to a normal string before joining it in the debug message or it will
cause runtime failures. Due to 2to3 overlooking the print statement
on line 513, this has also been corrected along with a check to see if
the repos variable is an instance of type str instead of type basestring
which is no longer available in py3.

---
 layman/api.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index f36be0a..763050d 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -90,7 +90,7 @@ class LaymanAPI(object):
         converting a string to a list[string] if it is not already a list.
         produces and error message if it is any other type
         returns repos as list always"""
-        if isinstance(repos, basestring):
+        if isinstance(repos, str):
             repos = [repos]
         # else assume it is an iterable, if not it will error
         return [encode(i) for i in repos]
@@ -299,7 +299,7 @@ class LaymanAPI(object):
         @param update_news: bool, defaults to False
         @rtype bool or {'repo-id': bool,...}
         """
-        self.output.debug("API.sync(); repos to sync = %s" % ', '.join(repos), 5)
+        self.output.debug("API.sync(); repos to sync = %s" % ', '.join(str(repos)), 5)
         fatals = []
         warnings = []
         success  = []
@@ -513,7 +513,7 @@ class LaymanAPI(object):
         self._error_messages.append(message)
         self.output.debug("API._error(); _error_messages = %s" % str(self._error_messages), 4)
         if self.report_errors:
-            print >>self.config['stderr'], message
+            print(message, file=self.config['stderr'])
 
 
     def get_errors(self):


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 21:15 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 21:15 UTC (permalink / raw
  To: gentoo-commits

commit:     ea812ff32370c426fb9c266b8824ba9338264c7c
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:10:50 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 21:10:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ea812ff3

layman/dbbase.py: Adds py3 unicode compatibility to ElementTree

When writing the database to installed.xml, ElementTree needs to have
an encoding type specified or run time errors will occur. To ensure
compatibility between py2/py3 a check has been made to see which
python version is running and to set the _unicode variable
accordingly.

---
 layman/dbbase.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index ff99965..3632a57 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -37,6 +37,14 @@ from   layman.utils              import indent
 from   layman.compatibility      import fileopen
 from   layman.overlays.overlay   import Overlay
 
+#py3.2
+if sys.hexversion >= 0x30200f0:
+    _unicode = 'unicode'
+else:
+    _unicode = 'UTF-8'
+
+
+
 #===============================================================================
 #
 # Class UnknownOverlayException
@@ -220,16 +228,13 @@ class DbBase(object):
         >>> os.rmdir(tmpdir)
         '''
 
-        tree = ET.Element('repositories', version="1.0")
+        tree = ET.Element('repositories', version="1.0", encoding="unicode")
         tree[:] = [e.to_xml() for e in list(self.overlays.values())]
         indent(tree)
         tree = ET.ElementTree(tree)
         try:
             f = fileopen(path, 'w')
-            f.write("""\
-<?xml version="1.0" encoding="UTF-8"?>
-""")
-            tree.write(f, encoding='utf-8')
+            tree.write(f, encoding=_unicode)
             f.close()
         except Exception as error:
             raise Exception('Failed to write to local overlays file: '


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 21:15 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 21:15 UTC (permalink / raw
  To: gentoo-commits

commit:     f3c9664657f2edf41e249cff378b7fb60e1262e2
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 20:56:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 20:56:23 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f3c96646

layman/config.py: Adds py3 compatibility for ConfigParser

---
 layman/config.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/layman/config.py b/layman/config.py
index bf33f50..0827b71 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -28,7 +28,14 @@ __version__ = "0.2"
 
 import sys
 import os
-import ConfigParser
+
+try:
+    # Import for Python3
+    import configparser as ConfigParser
+    from configparser import BasicInterpolation
+except:
+    # Import for Python2
+    import ConfigParser
 
 from layman.output import Message
 from layman.utils import path
@@ -247,6 +254,7 @@ class BareConfig(object):
                 return  overlays
         if (key in self._options
             and not self._options[key] is None):
+            self._options['config'] = '/etc/layman/layman.cfg'
             return self._options[key]
         if self.config and self.config.has_option('MAIN', key):
             if key in self._defaults['t/f_options']:


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 21:30 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 21:30 UTC (permalink / raw
  To: gentoo-commits

commit:     a9817274c76bf9c62f891615e55e5f4860580798
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:28:10 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 21:28:10 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a9817274

layman/makeconf.py: Implements cmp_to_key on prio_sort

To ensure py2/py3 compat, the cmp_to_key function has been used to
the convert the variable prio_sort to a key instead of a comparison
like py3 returns prio_sort to be.

---
 layman/makeconf.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/layman/makeconf.py b/layman/makeconf.py
index b592fc0..d8f0015 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -20,6 +20,7 @@ import codecs
 import re
 
 from layman.utils import path
+from layman.compatibility import cmp_to_key
 
 #===============================================================================
 #
@@ -246,7 +247,7 @@ class MakeConf:
                 return 1
             return 0
 
-        self.overlays.sort(prio_sort)
+        self.overlays.sort(key=cmp_to_key(prio_sort))
 
         paths = []
         for i in self.overlays:


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 21:42 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 21:42 UTC (permalink / raw
  To: gentoo-commits

commit:     b1d97b175f8dd5224e8c7d8ea6275daeda0e134c
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:33:55 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 21:33:55 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b1d97b17

layman/output.py: Adds file output compatibility

In order to allow users to set the output for error and normal
output we need to check to see if users have set the output to be
of type file. In py2 this is specified by the variable "file",
however in py3 this is specified by io.IOBase which encompasses
all file types such as Raw, Text, and Buffered files.

---
 layman/output.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ea98894..ef348f5 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -6,6 +6,7 @@
  Distributed under the terms of the GNU General Public License v2
 """
 
+from __future__ import print_function
 
 __version__ = "0.1"
 
@@ -15,6 +16,11 @@ import sys
 from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, NOTE_LEVEL, DEBUG_LEVEL, OFF
 from layman.compatibility import encode
 
+# py3.2
+if sys.hexversion >= 0x30200f0:
+    from io import IOBase as BUILTIN_FILE_TYPE
+else:
+    BUILTIN_FILE_TYPE=file
 
 class MessageBase(object):
     """Base Message class helper functions and variables
@@ -30,13 +36,13 @@ class MessageBase(object):
                  error_callback=None
                  ):
         # Where should the error output go? This can also be a file
-        if isinstance(err, file):
+        if isinstance(err, BUILTIN_FILE_TYPE):
             self.error_out = err
         else:
             raise Exception("MessageBase: input parameter 'err' must be of type: file")
 
         # Where should the normal output go? This can also be a file
-        if isinstance(out, file):
+        if isinstance(out, BUILTIN_FILE_TYPE):
             self.std_out = out
         else:
             raise Exception("MessageBase: input parameter 'out' must be of type: file")


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 22:08 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 22:08 UTC (permalink / raw
  To: gentoo-commits

commit:     88769793662332d31c3d937eb2dcbc9f895fda73
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:01 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 22:08:01 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=88769793

layman/utils.py: Adds proper str type checking for path_elements

---
 layman/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/utils.py b/layman/utils.py
index efb3231..bc8f473 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -149,7 +149,7 @@ def path(path_elements):
     '''
     pathname = ''
 
-    if type(path_elements) in types.StringTypes:
+    if isinstance(path_elements, str):
         path_elements = [path_elements]
 
     # Concatenate elements and seperate with /


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 22:16 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 22:16 UTC (permalink / raw
  To: gentoo-commits

commit:     4d712142d792cf5803428f9ec5f2a618c89b4135
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:45 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 22:08:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4d712142

layman/cli.py: Adds byte array support.

When checking the selection of which servers to sync/add there is
a check to see if 'ALL' is specified. In py2 with argparser this
works, but with py3 and argparser, this doesn't work because the
'ALL' string will come in as a bytearray. This commit fixes that
by checking the python version and assigned a varaible to be checked
instead of a simple string like 'ALL'. It will now come in as either
'ALL' or b'ALL', py version dependent. A small fix is also made to
docstring to make the print function py3 compatibile.

---
 layman/cli.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/layman/cli.py b/layman/cli.py
index cccddc6..460114a 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -30,7 +30,10 @@ from layman.utils import (decode_selection, encoder, get_encoding,
 from layman.constants import (NOT_OFFICIAL_MSG, NOT_SUPPORTED_MSG,
     FAILURE, SUCCEED)
 
-
+if sys.hexversion >= 0x30200f0:
+    ALL_KEYWORD = b'ALL'
+else:
+    ALL_KEYWORD = 'ALL'
 
 class ListPrinter(object):
     def __init__(self, config):
@@ -103,7 +106,7 @@ class ListPrinter(object):
 
     def short_list(self, overlay):
         '''
-        >>> print short_list(overlay)
+        >>> print(short_list(overlay))
         wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
         '''
         name   = pad(overlay['name'], 25)
@@ -184,7 +187,6 @@ class Main(object):
         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()):
@@ -234,13 +236,14 @@ class Main(object):
         '''
         self.output.info("Adding overlay,...", 2)
         selection = decode_selection(self.config['add'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
+            selection = str(selection)
             selection = self.api.get_available()
         self.output.debug('Adding selected overlays', 6)
         result = self.api.add_repos(selection, update_news=True)
         if result:
-            self.output.info('Successfully added overlay(s) '+\
-                ', '.join(selection) +'.', 2)
+            selection = b', '.join(selection)
+            self.output.info('Successfully added overlay(s) '+ selection.decode('UTF-8') +'.', 2)
         # blank newline  -- no " *"
         self.output.notice('')
         return result
@@ -253,7 +256,7 @@ class Main(object):
         self.output.info("Syncing selected overlays,...", 2)
         # Note api.sync() defaults to printing results
         selection = decode_selection(self.config['sync'])
-        if self.config['sync_all'] or 'ALL' in selection:
+        if self.config['sync_all'] or ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         self.output.debug('Updating selected overlays', 6)
         result = self.api.sync(selection, update_news=True)
@@ -267,7 +270,7 @@ class Main(object):
         '''
         self.output.info('Deleting selected overlays,...', 2)
         selection = decode_selection(self.config['delete'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         result = self.api.delete_repos(selection)
         if result:
@@ -282,7 +285,7 @@ class Main(object):
         ''' Print information about the specified overlays.
         '''
         selection = decode_selection(self.config['info'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_available()
 
         list_printer = ListPrinter(self.config)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     b1139ac8a94f20dac366d0e8bdb66e747d6e14c6
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May  7 22:17:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:43:55 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b1139ac8

{config, constants, output}.py: Adds notice level

The -q flag setting was being ignored by output.notice() calls.
Adding note_level to the output.notice() function makes it so
that the output will be quieted, if desired.

X-Gentoo-Bug: 457726
X-Gentoo-Bug-URL: https://bugs.gentoo.org/457726

---
 layman/config.py    |  1 +
 layman/constants.py |  1 +
 layman/output.py    | 19 ++++++++++++++++---
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 576ed05..bf33f50 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -228,6 +228,7 @@ class BareConfig(object):
     def _set_quietness(self, value):
             self._options['output'].set_info_level(value)
             self._options['output'].set_warn_level(value)
+            self._options['output'].set_note_level(value)
 
     def __getitem__(self, key):
         return self._get_(key)

diff --git a/layman/constants.py b/layman/constants.py
index 6f53de3..9a2af40 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -48,6 +48,7 @@ NOT_SUPPORTED_MSG = '*** You are lacking the necessary tools' +\
 OFF = 0
 WARN_LEVEL = 4
 INFO_LEVEL = 4
+NOTE_LEVEL = 4
 DEBUG_LEVEL = 4
 DEBUG_VERBOSITY = 2
 

diff --git a/layman/output.py b/layman/output.py
index b48531a..48b44a1 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -12,7 +12,7 @@ __version__ = "0.1"
 
 import sys
 
-from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL, OFF
+from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, NOTE_LEVEL, DEBUG_LEVEL, OFF
 from layman.compatibility import encode
 
 
@@ -25,6 +25,7 @@ class MessageBase(object):
                  err = sys.stderr,
                  info_level = INFO_LEVEL,
                  warn_level = WARN_LEVEL,
+                 note_level = NOTE_LEVEL,
                  col = True,
                  error_callback=None
                  ):
@@ -46,6 +47,9 @@ class MessageBase(object):
         # The higher the level the more information you will get
         self.info_lev = info_level
 
+        # The higher the level the more information you will get
+        self.note_lev = note_level
+
         # Should the output be colored?
         self.color_func = None
         self.set_colorize(col)
@@ -81,6 +85,10 @@ class MessageBase(object):
         self.warn_lev = warn_level
 
 
+    def set_note_level(self, note_level = NOTE_LEVEL):
+        self.note_lev = note_level
+
+
     def set_debug_level(self, debugging_level = DEBUG_LEVEL):
         self.debug_lev = debugging_level
 
@@ -103,12 +111,13 @@ class Message(MessageBase):
                  err = sys.stderr,
                  info_level = INFO_LEVEL,
                  warn_level = WARN_LEVEL,
+                 note_level = NOTE_LEVEL,
                  col = True,
                  error_callback = None
                 ):
 
         MessageBase.__init__(self, out, err, info_level, warn_level,
-            col, error_callback)
+            note_level, col, error_callback)
 
 
     ## Output Functions
@@ -127,7 +136,11 @@ class Message(MessageBase):
             print  >> self.std_out, self.color_func('yellow', 'DEBUG: ') + i
 
 
-    def notice (self, note):
+    def notice (self, note, level = NOTE_LEVEL):
+
+        if level > self.note_lev:
+            return
+
         print >> self.std_out, note
 
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     f045ecb72e58afbd5ef51dceac126bc93d6bc249
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 03:21:13 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:46:05 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f045ecb7

dbbase.py: Adds compatibility to exception handling.

---
 layman/dbbase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 8d57a9f..475ce44 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -156,7 +156,7 @@ class DbBase(object):
         '''
         try:
             document = ET.fromstring(text)
-        except xml.parsers.expat.ExpatError, error:
+        except xml.parsers.expat.ExpatError as error:
             raise BrokenOverlayCatalog(origin, error, self._broken_catalog_hint())
 
         overlays = document.findall('overlay') + \


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     c939413d4d3bb469d47af31ec71b7b089258ea27
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 18:54:56 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:47:11 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c939413d

layman/{output, version}.py: Updates print() functions

---
 layman/output.py  | 16 ++++++++--------
 layman/version.py |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index 48b44a1..ea98894 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -133,7 +133,7 @@ class Message(MessageBase):
             return
 
         for i in info.split('\n'):
-            print  >> self.std_out, self.color_func('yellow', 'DEBUG: ') + i
+            print(self.color_func('yellow', 'DEBUG: ') + i, file=self.std_out)
 
 
     def notice (self, note, level = NOTE_LEVEL):
@@ -141,7 +141,7 @@ class Message(MessageBase):
         if level > self.note_lev:
             return
 
-        print >> self.std_out, note
+        print(note, file=self.std_out)
 
 
     def info (self, info, level = INFO_LEVEL):
@@ -153,7 +153,7 @@ class Message(MessageBase):
             return
 
         for i in info.split('\n'):
-            print  >> self.std_out, " %s %s" % (self.color_func('green', '*'),i)
+            print(" %s %s" % (self.color_func('green', '*'),i), file=self.std_out)
 
 
     def status (self, message, status, info = 'ignored'):
@@ -167,7 +167,7 @@ class Message(MessageBase):
             return
 
         for i in lines[0:-1]:
-            print >> self.std_out, " %s %s" % (self.color_func('green', '*'),i)
+            print(" %s %s" % (self.color_func('green', '*'),i), file=self.std_out)
 
         i = lines[-1]
 
@@ -181,8 +181,8 @@ class Message(MessageBase):
         else:
             result = '[' + self.color_func('yellow', info) + ']'
 
-        print >> " %s %s %s %S" % (self.color_func('green', '*'), i,
-            ('.' * (58 - len(i))), result)
+        print(file=" %s %s %s %S" % (self.color_func('green', '*'), i,
+            ('.' * (58 - len(i))), result))
 
 
     def warn (self, warn, level = WARN_LEVEL):
@@ -194,7 +194,7 @@ class Message(MessageBase):
             return
 
         for i in warn.split('\n'):
-            print >> self.std_out, " %s %s" % (self.color_func('yellow', '*'),i)
+            print(" %s %s" % (self.color_func('yellow', '*'),i), file=self.std_out)
 
 
     def error (self, error):
@@ -208,7 +208,7 @@ class Message(MessageBase):
             # "layman -L |& less".
             self.std_out.flush()
             self.error_out.flush()
-            print >> self.std_out, " %s %s" % (self.color_func('red', '*'), i)
+            print(" %s %s" % (self.color_func('red', '*'), i), file=self.std_out)
             self.std_out.flush()
         self.do_error_callback(error)
 

diff --git a/layman/version.py b/layman/version.py
index 90c7412..276ee86 100644
--- a/layman/version.py
+++ b/layman/version.py
@@ -25,4 +25,4 @@ __version__ = "$Id: version.py 309 2007-04-09 16:23:38Z wrobel $"
 VERSION = '2.0.0-git'
 
 if __name__ == '__main__':
-    print VERSION
+    print(VERSION)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     9d3bec661c85a9121b2c42d9b1375aceb7a40e65
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 23:47:11 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=9d3bec66

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


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     6c71e2cc127a3271dcdd0a0e3228bc4514b6442a
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 20:56:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:47:43 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6c71e2cc

layman/config.py: Adds py3 compatibility for ConfigParser

---
 layman/config.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/layman/config.py b/layman/config.py
index bf33f50..0827b71 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -28,7 +28,14 @@ __version__ = "0.2"
 
 import sys
 import os
-import ConfigParser
+
+try:
+    # Import for Python3
+    import configparser as ConfigParser
+    from configparser import BasicInterpolation
+except:
+    # Import for Python2
+    import ConfigParser
 
 from layman.output import Message
 from layman.utils import path
@@ -247,6 +254,7 @@ class BareConfig(object):
                 return  overlays
         if (key in self._options
             and not self._options[key] is None):
+            self._options['config'] = '/etc/layman/layman.cfg'
             return self._options[key]
         if self.config and self.config.has_option('MAIN', key):
             if key in self._defaults['t/f_options']:


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     dfbbf55260e78477d8ee5f6843f4f055d60c5433
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:10:50 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:47:43 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=dfbbf552

dbbase.py: Adds unicode compatibility to ElementTree

When writing the database to installed.xml, ElementTree needs to have
an encoding type specified or run time errors will occur. To ensure
compatibility between py2/py3 a check has been made to see which
python version is running and to set the _unicode variable
accordingly.

---
 layman/dbbase.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index ff99965..3632a57 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -37,6 +37,14 @@ from   layman.utils              import indent
 from   layman.compatibility      import fileopen
 from   layman.overlays.overlay   import Overlay
 
+#py3.2
+if sys.hexversion >= 0x30200f0:
+    _unicode = 'unicode'
+else:
+    _unicode = 'UTF-8'
+
+
+
 #===============================================================================
 #
 # Class UnknownOverlayException
@@ -220,16 +228,13 @@ class DbBase(object):
         >>> os.rmdir(tmpdir)
         '''
 
-        tree = ET.Element('repositories', version="1.0")
+        tree = ET.Element('repositories', version="1.0", encoding="unicode")
         tree[:] = [e.to_xml() for e in list(self.overlays.values())]
         indent(tree)
         tree = ET.ElementTree(tree)
         try:
             f = fileopen(path, 'w')
-            f.write("""\
-<?xml version="1.0" encoding="UTF-8"?>
-""")
-            tree.write(f, encoding='utf-8')
+            tree.write(f, encoding=_unicode)
             f.close()
         except Exception as error:
             raise Exception('Failed to write to local overlays file: '


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     5e68bb3140abaf79ecfef0e37459939d795560fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:28:10 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:48:18 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=5e68bb31

layman/makeconf.py: Implements cmp_to_key on prio_sort

To ensure py2/py3 compat, the cmp_to_key function has been used to
the convert the variable prio_sort to a key instead of a comparison
like py3 returns prio_sort to be.

---
 layman/makeconf.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/layman/makeconf.py b/layman/makeconf.py
index b592fc0..d8f0015 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -20,6 +20,7 @@ import codecs
 import re
 
 from layman.utils import path
+from layman.compatibility import cmp_to_key
 
 #===============================================================================
 #
@@ -246,7 +247,7 @@ class MakeConf:
                 return 1
             return 0
 
-        self.overlays.sort(prio_sort)
+        self.overlays.sort(key=cmp_to_key(prio_sort))
 
         paths = []
         for i in self.overlays:


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     852864fc72515a50db0296119317d4b0d9ea369d
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:33:55 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:48:18 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=852864fc

layman/output.py: Adds file output compatibility

In order to allow users to set the output for error and normal
output we need to check to see if users have set the output to be
of type file. In py2 this is specified by the variable "file",
however in py3 this is specified by io.IOBase which encompasses
all file types such as Raw, Text, and Buffered files.

---
 layman/output.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ea98894..ef348f5 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -6,6 +6,7 @@
  Distributed under the terms of the GNU General Public License v2
 """
 
+from __future__ import print_function
 
 __version__ = "0.1"
 
@@ -15,6 +16,11 @@ import sys
 from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, NOTE_LEVEL, DEBUG_LEVEL, OFF
 from layman.compatibility import encode
 
+# py3.2
+if sys.hexversion >= 0x30200f0:
+    from io import IOBase as BUILTIN_FILE_TYPE
+else:
+    BUILTIN_FILE_TYPE=file
 
 class MessageBase(object):
     """Base Message class helper functions and variables
@@ -30,13 +36,13 @@ class MessageBase(object):
                  error_callback=None
                  ):
         # Where should the error output go? This can also be a file
-        if isinstance(err, file):
+        if isinstance(err, BUILTIN_FILE_TYPE):
             self.error_out = err
         else:
             raise Exception("MessageBase: input parameter 'err' must be of type: file")
 
         # Where should the normal output go? This can also be a file
-        if isinstance(out, file):
+        if isinstance(out, BUILTIN_FILE_TYPE):
             self.std_out = out
         else:
             raise Exception("MessageBase: input parameter 'out' must be of type: file")


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     aabb88312cb2e07a1a48b9017dda4012696b867c
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 19:24:59 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:47:11 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=aabb8831

layman/api.py: Corrects output of repos and stderr

Due to repos coming in as a binary string, it needed to be converted
to a normal string before joining it in the debug message or it will
cause runtime failures. Due to 2to3 overlooking the print statement
on line 513, this has also been corrected along with a check to see if
the repos variable is an instance of type str instead of type basestring
which is no longer available in py3.

---
 layman/api.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index f36be0a..763050d 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -90,7 +90,7 @@ class LaymanAPI(object):
         converting a string to a list[string] if it is not already a list.
         produces and error message if it is any other type
         returns repos as list always"""
-        if isinstance(repos, basestring):
+        if isinstance(repos, str):
             repos = [repos]
         # else assume it is an iterable, if not it will error
         return [encode(i) for i in repos]
@@ -299,7 +299,7 @@ class LaymanAPI(object):
         @param update_news: bool, defaults to False
         @rtype bool or {'repo-id': bool,...}
         """
-        self.output.debug("API.sync(); repos to sync = %s" % ', '.join(repos), 5)
+        self.output.debug("API.sync(); repos to sync = %s" % ', '.join(str(repos)), 5)
         fatals = []
         warnings = []
         success  = []
@@ -513,7 +513,7 @@ class LaymanAPI(object):
         self._error_messages.append(message)
         self.output.debug("API._error(); _error_messages = %s" % str(self._error_messages), 4)
         if self.report_errors:
-            print >>self.config['stderr'], message
+            print(message, file=self.config['stderr'])
 
 
     def get_errors(self):


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     bcb2618ef62db616faca4e8d5c8ab56a45503609
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:01 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:48:18 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=bcb2618e

utils.py: Adds str type checking for path_elements

---
 layman/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/utils.py b/layman/utils.py
index efb3231..bc8f473 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -149,7 +149,7 @@ def path(path_elements):
     '''
     pathname = ''
 
-    if type(path_elements) in types.StringTypes:
+    if isinstance(path_elements, str):
         path_elements = [path_elements]
 
     # Concatenate elements and seperate with /


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:49 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:49 UTC (permalink / raw
  To: gentoo-commits

commit:     de51b86ca9c283e700d5110a709a7e351790cc64
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:45 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:48:53 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=de51b86c

layman/cli.py: Adds byte array support

When checking the selection of which servers to sync/add there is
a check to see if 'ALL' is specified. In py2 with argparser this
works, but with py3 and argparser, this doesn't work because the
'ALL' string will come in as a bytearray. This commit fixes that
by checking the python version and assigning a varaible to be checked
instead of a simple string like 'ALL'. It will now come in as either
'ALL' or b'ALL', py version dependent. A small fix is also made to
docstring to make the print function py3 compatibile.

---
 layman/cli.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/layman/cli.py b/layman/cli.py
index cccddc6..460114a 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -30,7 +30,10 @@ from layman.utils import (decode_selection, encoder, get_encoding,
 from layman.constants import (NOT_OFFICIAL_MSG, NOT_SUPPORTED_MSG,
     FAILURE, SUCCEED)
 
-
+if sys.hexversion >= 0x30200f0:
+    ALL_KEYWORD = b'ALL'
+else:
+    ALL_KEYWORD = 'ALL'
 
 class ListPrinter(object):
     def __init__(self, config):
@@ -103,7 +106,7 @@ class ListPrinter(object):
 
     def short_list(self, overlay):
         '''
-        >>> print short_list(overlay)
+        >>> print(short_list(overlay))
         wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
         '''
         name   = pad(overlay['name'], 25)
@@ -184,7 +187,6 @@ class Main(object):
         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()):
@@ -234,13 +236,14 @@ class Main(object):
         '''
         self.output.info("Adding overlay,...", 2)
         selection = decode_selection(self.config['add'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
+            selection = str(selection)
             selection = self.api.get_available()
         self.output.debug('Adding selected overlays', 6)
         result = self.api.add_repos(selection, update_news=True)
         if result:
-            self.output.info('Successfully added overlay(s) '+\
-                ', '.join(selection) +'.', 2)
+            selection = b', '.join(selection)
+            self.output.info('Successfully added overlay(s) '+ selection.decode('UTF-8') +'.', 2)
         # blank newline  -- no " *"
         self.output.notice('')
         return result
@@ -253,7 +256,7 @@ class Main(object):
         self.output.info("Syncing selected overlays,...", 2)
         # Note api.sync() defaults to printing results
         selection = decode_selection(self.config['sync'])
-        if self.config['sync_all'] or 'ALL' in selection:
+        if self.config['sync_all'] or ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         self.output.debug('Updating selected overlays', 6)
         result = self.api.sync(selection, update_news=True)
@@ -267,7 +270,7 @@ class Main(object):
         '''
         self.output.info('Deleting selected overlays,...', 2)
         selection = decode_selection(self.config['delete'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         result = self.api.delete_repos(selection)
         if result:
@@ -282,7 +285,7 @@ class Main(object):
         ''' Print information about the specified overlays.
         '''
         selection = decode_selection(self.config['info'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_available()
 
         list_printer = ListPrinter(self.config)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-14 23:54 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-14 23:54 UTC (permalink / raw
  To: gentoo-commits

commit:     f14997a82324e6f3c708b19e0ca0fd38f89a8027
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 23:52:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:52:23 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f14997a8

dbbase.py: Fixes implicit tuple unpacking

A temporary variable is assigned to fix the lack of implicit tuple
unpacking in py3.

---
 layman/dbbase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 3632a57..1cbf0bb 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -312,7 +312,7 @@ class DbBase(object):
                 result.append((overlay.short_list(width), overlay.is_supported(),
                                overlay.is_official()))
 
-        result = sorted(result, key=lambda (summary, supported, official): summary.lower())
+        result = sorted(result, key=lambda summary_supported_official: summary_supported_official[0].lower())
 
         return result
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-15  0:04 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-15  0:04 UTC (permalink / raw
  To: gentoo-commits

commit:     66a016301c43646cc121867f9ede8466884beae7
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 23:58:29 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Wed May 14 23:58:29 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=66a01630

argsparser.py: Migrates from optparse to argparse

Included with this patch is another flag, -C for config dir as well
as default values for configdir, config, and overlay_defs. Also
included is interpolation of these variables, because argparse lacks
the necessary interpolation.

---
 layman/argsparser.py | 361 ++++++++++++++++++++++++++-------------------------
 1 file changed, 183 insertions(+), 178 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index dd1cc85..63c8618 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -31,7 +31,7 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
 
 import sys
 
-from optparse import OptionParser, OptionGroup
+from argparse import ArgumentParser as OptionParser
 
 from layman.config import BareConfig
 from layman.constants import OFF
@@ -71,178 +71,182 @@ class ArgsParser(BareConfig):
 
         BareConfig.__init__(self, stdout=stdout, stderr=stderr,
                             stdin=stdin, root=root)
-        if args == None:
-            args = sys.argv
 
         # get a couple BareConfig items
         self.defaults = self.get_defaults()
         self.output = self.get_option('output')
 
         self.parser = OptionParser(
-            usage   = _USAGE,
-            version = VERSION)
+            usage   = _USAGE)
 
-        self.parser.add_option('-H',
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
+        self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
-
         #-----------------------------------------------------------------
         # Main Options
 
-        group = OptionGroup(self.parser,
-                            '<Actions>')
-
-        group.add_option('-a',
-                         '--add',
-                         action = 'append',
-                         help = 'Add the given overlay from the cached remote li'
-                         'st to your locally installed overlays.. Specify "ALL" '
-                         'to add all overlays from the remote list.')
-
-        group.add_option('-d',
-                         '--delete',
-                         action = 'append',
-                         help = 'Remove the given overlay from your locally inst'
-                         'alled overlays. Specify "ALL" to remove all overlays')
-
-        group.add_option('-s',
-                         '--sync',
-                         action = 'append',
-                         help = 'Update the specified overlay. Use "ALL" as para'
-                         'meter to synchronize all overlays')
-
-        group.add_option('-i',
-                         '--info',
-                         action = 'append',
-                         help = 'Display information about the specified overlay'
-                         '.')
-
-        group.add_option('-S',
-                         '--sync-all',
-                         action = 'store_true',
-                         help = 'Update all overlays.')
-
-        group.add_option('-L',
-                         '--list',
-                         action = 'store_true',
-                         help = 'List the contents of the remote list.')
-
-        group.add_option('-l',
-                         '--list-local',
-                         action = 'store_true',
-                         help = 'List the locally installed overlays.')
-
-        group.add_option('-f',
-                         '--fetch',
-                         action = 'store_true',
-                         help = 'Fetch a remote list of overlays. This option is'
-                         ' deprecated. The fetch operation will be performed by '
-                         'default when you run sync, sync-all, or list.')
-
-        group.add_option('-n',
-                         '--nofetch',
-                         action = 'store_true',
-                         help = 'Do not fetch a remote list of overlays.')
-
-        group.add_option('-p',
-                         '--priority',
-                         action = 'store',
-                         help = 'Use this with the --add switch to set the prior'
-                         'ity of the added overlay. This will influence the sort'
-                         'ing order of the overlays in the PORTDIR_OVERLAY varia'
-                         'ble.')
-
-        self.parser.add_option_group(group)
+        actions = self.parser.add_argument_group('<Actions>')
+
+        actions.add_argument('-a',
+                             '--add',
+                             action = 'append',
+                             help = 'Add the given overlay from the cached remote li'
+                             'st to your locally installed overlays.. Specify "ALL" '
+                             'to add all overlays from the remote list.')
+
+        actions.add_argument('-d',
+                             '--delete',
+                             action = 'append',
+                             help = 'Remove the given overlay from your locally inst'
+                             'alled overlays. Specify "ALL" to remove all overlays.')
+
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-i',
+                             '--info',
+                             action = 'append',
+                             help = 'Display information about the specified overlay'
+                             '.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
+        actions.add_argument('-L',
+                             '--list',
+                             action = 'store_true',
+                             help = 'List the contents of the remote list.')
+
+        actions.add_argument('-l',
+                             '--list-local',
+                             action = 'store_true',
+                             help = 'List the locally installed overlays.')
+
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
+
+        actions.add_argument('-n',
+                             '--nofetch',
+                             action = 'store_true',
+                             help = 'Do not fetch a remote list of overlays.')
+
+        actions.add_argument('-p',
+                             '--priority',
+                             action = 'store',
+                             help = 'Use this with the --add switch to set the prior'
+                             'ity of the added overlay. This will influence the sort'
+                             'ing order of the overlays in the PORTDIR_OVERLAY varia'
+                             'ble.')
 
         #-----------------------------------------------------------------
         # Additional Options
 
-        group = OptionGroup(self.parser,
-                            '<Path options>')
+        path_opts = self.parser.add_argument_group('<Path options>')
+
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
+
+        path_opts.add_argument('-c',
+                               '--config',
+                               action = 'store',
+                               default = self.defaults['config'],
+                               # Force interpolation (to prevent argparse tracebacks)
+                               help = 'Path to the config file [default: '
+                               '%s].' % (self.defaults['config'] %self.defaults))
 
-        group.add_option('-c',
-                         '--config',
-                         action = 'store',
-                         help = 'Path to the config file [default: ' \
-                         + self.defaults['config'] + '].')
 
-        group.add_option('-O',
-                         '--overlay_defs',
-                         action = 'store',
-                         help = 'Path to aditional overlay.xml files [default: '\
-                         + self.defaults['overlay_defs'] + '].')
 
-        group.add_option('-o',
-                         '--overlays',
-                         action = 'append',
-                         help = 'The list of overlays [default: ' \
-                         + self.defaults['overlays'] + '].')
+        path_opts.add_argument('-O',
+                               '--overlay_defs',
+                               action = 'store',
+                               default = self.defaults['overlay_defs'],
+                               # Force interpolation (to prevent argparse tracebacks)
+                               help = 'Path to aditional overlay.xml files [default: '
+                               '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        self.parser.add_option_group(group)
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         #-----------------------------------------------------------------
         # Output Options
 
-        group = OptionGroup(self.parser,
-                            '<Output options>')
-
-        group.add_option('-v',
-                         '--verbose',
-                         action = 'store_true',
-                         help = 'Increase the amount of output and describe the '
-                         'overlays.')
-
-        group.add_option('-q',
-                         '--quiet',
-                         action = 'store_true',
-                         help = 'Yield no output. Please be careful with this op'
-                         'tion: If the processes spawned by layman when adding o'
-                         'r synchronizing overlays require any input layman will'
-                         ' hang without telling you why. This might happen for e'
-                         'xample if your overlay resides in subversion and the S'
-                         'SL certificate of the server needs acceptance.')
-
-        group.add_option('-N',
-                         '--nocolor',
-                         action = 'store_true',
-                         help = 'Remove color codes from the layman output.')
-
-        group.add_option('-Q',
-                         '--quietness',
-                         action = 'store',
-                         type = 'int',
-                         default = '4',
-                         help = 'Set the level of output (0-4). Default: 4. Once'
-                         ' you set this below 2 the same warning as given for --'
-                         'quiet applies! ')
-
-        group.add_option('-W',
-                         '--width',
-                         action = 'store',
-                         type = 'int',
-                         default = '0',
-                         help = 'Sets the screen width. This setting is usually '
-                         'not required as layman is capable of detecting the '
-                         'available number of columns automatically.')
-
-        group.add_option('-k',
-                         '--nocheck',
-                         action = 'store_true',
-                         help = 'Do not check overlay definitions and do not i'
-                         'ssue a warning if description or contact information'
-                         ' are missing.')
-
-        group.add_option('--debug-level',
-                         action = 'store',
-                         type = 'int',
-                         help = 'A value between 0 and 10. 0 means no debugging '
-                         'messages will be selected, 10 selects all debugging me'
-                         'ssages. Default is "4".')
-
-
-        self.parser.add_option_group(group)
+        out_opts = self.parser.add_argument_group('<Output options>')
+
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
+        out_opts.add_argument('-q',
+                              '--quiet',
+                              action = 'store_true',
+                              help = 'Yield no output. Please be careful with this op'
+                              'tion: If the processes spawned by layman when adding o'
+                              'r synchronizing overlays require any input layman will'
+                              ' hang without telling you why. This might happen for e'
+                              'xample if your overlay resides in subversion and the S'
+                              'SL certificate of the server needs acceptance.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
+
+        out_opts.add_argument('-Q',
+                              '--quietness',
+                              action = 'store',
+                              type = int,
+                              default = 4,
+                              help = 'Set the level of output (0-4). Default: 4. Once'
+                              ' you set this below 2 the same warning as given for --'
+                              'quiet applies!')
+
+        out_opts.add_argument('-W',
+                              '--width',
+                              action = 'store',
+                              type = int,
+                              default = 0,
+                              help = 'Sets the screen width. This setting is usually '
+                              'not required as layman is capable of detecting the '
+                              'available number of columns automatically.')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
+                              action = 'store_true',
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
 
         #-----------------------------------------------------------------
         # Debug Options
@@ -251,45 +255,46 @@ class ArgsParser(BareConfig):
 
         # Parse the command line first since we need to get the config
         # file option.
-        if len(args) == 1:
-            self.output.notice('Usage:%s' % _USAGE)
-            sys.exit(0)
 
-        (self.options, remain_args) = self.parser.parse_args(args)
-        # remain_args starts with something like "bin/layman" ...
-        if len(remain_args) > 1:
-            self.parser.error("ArgsParser(): Unhandled parameters: %s"
-                % ', '.join(('"%s"' % e) for e in remain_args[1:]))
+        # If no flags are present print out usage
+        if len(sys.argv) == 1:
+            self.output.notice('usage:%s' % _USAGE)
+            sys.exit(0)
 
-        # handle debugging
-        #self.output.cli_handle(self.options)
+        self.options = self.parser.parse_args()
+        self.options = vars(self.options)
+        # Applying interpolation of values
+        for v in ['configdir', 'config', 'overlay_defs']:
+            self.options[v] = self.options[v] % self.options
+            self.defaults[v] = self.options[v]
 
-        if (self.options.__dict__.has_key('debug_level') and
-            self.options.__dict__['debug_level']):
-            dbglvl = int(self.options.__dict__['debug_level'])
+        if ('debug_level' in self.options and
+            self.options['debug_level']):
+            dbglvl = int(self.options['debug_level'])
             if dbglvl < 0:
                 dbglvl = 0
             if dbglvl > 10:
                 dbglvl = 10
             self.output.set_debug_level(dbglvl)
 
-        if self.options.__dict__['nocolor']:
+        if self.options['nocolor']:
             self.output.set_colorize(OFF)
 
         # Set only alternate config settings from the options
-        if self.options.__dict__['config'] is not None:
-            self.defaults['config'] = self.options.__dict__['config']
+        if self.options['config'] is not None:
+            self.defaults['config'] = self.options['config']
             self.output.debug('ARGSPARSER: Got config file at ' + \
                 self.defaults['config'], 8)
         else: # fix the config path
             self.defaults['config'] = self.defaults['config'] \
                 % {'configdir': self.defaults['configdir']}
-        if self.options.__dict__['overlay_defs'] is not None:
-            self.defaults['overlay_defs'] = self.options.__dict__['overlay_defs']
+
+        if self.options['overlay_defs'] is not None:
+            self.defaults['overlay_defs'] = self.options['overlay_defs']
             self.output.debug('ARGSPARSER: Got overlay_defs location at ' + \
                 self.defaults['overlay_defs'], 8)
 
-        self._options['setup_help'] = self.options.__dict__['setup_help']
+        self._options['setup_help'] = self.options['setup_help']
 
         # Now parse the config file
         self.output.debug('ARGSPARSER: Reading config file at ' + \
@@ -297,19 +302,19 @@ class ArgsParser(BareConfig):
         self.read_config(self.defaults)
 
         # handle quietness
-        if self.options.__dict__['quiet']:
+        if self.options['quiet']:
             self.set_option('quiet', True)
-        elif self.options.__dict__['quietness']:
-            self.set_option('quietness', self.options.__dict__['quietness'])
+        elif self.options['quietness']:
+            self.set_option('quietness', self.options['quietness'])
 
 
     def __getitem__(self, key):
 
         if key == 'overlays':
             overlays = ''
-            if (key in list(self.options.__dict__.keys())
-                and not self.options.__dict__[key] is None):
-                overlays = '\n'.join(self.options.__dict__[key])
+            if (key in list(self.options.keys())
+                and not self.options[key] is None):
+                overlays = '\n'.join(self.options[key])
             if self.config.has_option('MAIN', 'overlays'):
                 overlays += '\n' + self.config.get('MAIN', 'overlays')
             if len(overlays):
@@ -317,9 +322,9 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving options option: %s' % key, 9)
 
-        if (key in list(self.options.__dict__.keys())
-            and not self.options.__dict__[key] is None):
-            return self.options.__dict__[key]
+        if (key in list(self.options.keys())
+            and not self.options[key] is False):
+            return self.options[key]
 
         self.output.debug('ARGSPARSER: Retrieving config option: %s' % key, 9)
 
@@ -346,8 +351,9 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving keys', 9)
 
-        keys = [i for i in list(self.options.__dict__.keys())
-                if not self.options.__dict__[i] is None]
+        keys = [i for i in list(self.options)
+                if not self.options[i] is False
+                and not self.options[i] is None]
 
         self.output.debug('ARGSPARSER: Retrieving keys 2', 9)
 
@@ -358,7 +364,6 @@ class ArgsParser(BareConfig):
 
         keys += [i for i in list(self.defaults.keys())
                  if not i in keys]
-
         self.output.debug('ARGSPARSER: Returning keys', 9)
 
         return keys


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-15 20:02 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-15 20:02 UTC (permalink / raw
  To: gentoo-commits

commit:     faae36cf96ba76ecbbcb96e01bd7de018a1fdf69
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 19:58:36 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu May 15 19:58:36 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=faae36cf

argsparser.py: Aplhabetizes group arguments

---
 layman/argsparser.py | 114 +++++++++++++++++++++++++--------------------------
 1 file changed, 56 insertions(+), 58 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 63c8618..5b85456 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -79,16 +79,16 @@ class ArgsParser(BareConfig):
         self.parser = OptionParser(
             usage   = _USAGE)
 
-        self.parser.add_argument('-V',
-                          '--version',
-                          action = 'version',
-                          version = VERSION)
-
         self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
         #-----------------------------------------------------------------
         # Main Options
 
@@ -107,11 +107,12 @@ class ArgsParser(BareConfig):
                              help = 'Remove the given overlay from your locally inst'
                              'alled overlays. Specify "ALL" to remove all overlays.')
 
-        actions.add_argument('-s',
-                             '--sync',
-                             action = 'append',
-                             help = 'Update the specified overlay. Use "ALL" as para'
-                            'meter to synchronize all overlays.')
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
 
         actions.add_argument('-i',
                              '--info',
@@ -119,11 +120,6 @@ class ArgsParser(BareConfig):
                              help = 'Display information about the specified overlay'
                              '.')
 
-        actions.add_argument('-S',
-                             '--sync-all',
-                             action = 'store_true',
-                             help = 'Update all overlays.')
-
         actions.add_argument('-L',
                              '--list',
                              action = 'store_true',
@@ -134,13 +130,6 @@ class ArgsParser(BareConfig):
                              action = 'store_true',
                              help = 'List the locally installed overlays.')
 
-        actions.add_argument('-f',
-                             '--fetch',
-                             action = 'store_true',
-                             help = 'Fetch a remote list of overlays. This option is'
-                             ' deprecated. The fetch operation will be performed by '
-                             'default when you run sync, sync-all, or list.')
-
         actions.add_argument('-n',
                              '--nofetch',
                              action = 'store_true',
@@ -154,18 +143,22 @@ class ArgsParser(BareConfig):
                              'ing order of the overlays in the PORTDIR_OVERLAY varia'
                              'ble.')
 
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
         #-----------------------------------------------------------------
         # Additional Options
 
         path_opts = self.parser.add_argument_group('<Path options>')
 
-        path_opts.add_argument('-C',
-                               '--configdir',
-                               action = 'store',
-                               default = '/etc/layman',
-                               help = 'Directory path to user for all layman configu'
-                               'ration information [default: /etc/layman].')
-
         path_opts.add_argument('-c',
                                '--config',
                                action = 'store',
@@ -174,7 +167,18 @@ class ArgsParser(BareConfig):
                                help = 'Path to the config file [default: '
                                '%s].' % (self.defaults['config'] %self.defaults))
 
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
 
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         path_opts.add_argument('-O',
                                '--overlay_defs',
@@ -184,22 +188,29 @@ class ArgsParser(BareConfig):
                                help = 'Path to aditional overlay.xml files [default: '
                                '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        path_opts.add_argument('-o',
-                               '--overlays',
-                               action = 'append',
-                               help = 'The list of overlays [default: ' \
-                               + self.defaults['overlays'] + '].')
-
         #-----------------------------------------------------------------
         # Output Options
 
         out_opts = self.parser.add_argument_group('<Output options>')
 
-        out_opts.add_argument('-v',
-                              '--verbose',
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
                               action = 'store_true',
-                              help = 'Increase the amount of output and describe the '
-                              'overlays.')
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
 
         out_opts.add_argument('-q',
                               '--quiet',
@@ -211,11 +222,6 @@ class ArgsParser(BareConfig):
                               'xample if your overlay resides in subversion and the S'
                               'SL certificate of the server needs acceptance.')
 
-        out_opts.add_argument('-N',
-                              '--nocolor',
-                              action = 'store_true',
-                              help = 'Remove color codes from the layman output.')
-
         out_opts.add_argument('-Q',
                               '--quietness',
                               action = 'store',
@@ -225,6 +231,12 @@ class ArgsParser(BareConfig):
                               ' you set this below 2 the same warning as given for --'
                               'quiet applies!')
 
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
         out_opts.add_argument('-W',
                               '--width',
                               action = 'store',
@@ -234,20 +246,6 @@ class ArgsParser(BareConfig):
                               'not required as layman is capable of detecting the '
                               'available number of columns automatically.')
 
-        out_opts.add_argument('-k',
-                              '--nocheck',
-                              action = 'store_true',
-                              help = 'Do not check overlay definitions and do not i'
-                              'ssue a warning if description or contact information'
-                              ' are missing.')
-
-        out_opts.add_argument('--debug-level',
-                              action = 'store',
-                              type = int,
-                              help = 'A value between 0 and 10. 0 means no debugging '
-                              'messages will be selected, 10 selects all debugging me'
-                              'ssages. Default is "4".')
-
         #-----------------------------------------------------------------
         # Debug Options
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-15 20:30 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-15 20:30 UTC (permalink / raw
  To: gentoo-commits

commit:     e718f376c52f5cc682bc3b2e07081e3ce0861a2d
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 20:30:09 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu May 15 20:30:09 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e718f376

argsparser.py: Removes OptParser remnants

---
 layman/argsparser.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 5b85456..5b94530 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -31,7 +31,7 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
 
 import sys
 
-from argparse import ArgumentParser as OptionParser
+from argparse import ArgumentParser
 
 from layman.config import BareConfig
 from layman.constants import OFF
@@ -76,7 +76,7 @@ class ArgsParser(BareConfig):
         self.defaults = self.get_defaults()
         self.output = self.get_option('output')
 
-        self.parser = OptionParser(
+        self.parser = ArgumentParser(
             usage   = _USAGE)
 
         self.parser.add_argument('-H',


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-15 20:37 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-15 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f96fd88b94ee1ef9b85f1dd6dc41e2b98c3bb299
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 20:30:09 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu May 15 20:35:58 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f96fd88b

argsparser.py: Removes OptParser remnants

---
 layman/argsparser.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 5b85456..5b94530 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -31,7 +31,7 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
 
 import sys
 
-from argparse import ArgumentParser as OptionParser
+from argparse import ArgumentParser
 
 from layman.config import BareConfig
 from layman.constants import OFF
@@ -76,7 +76,7 @@ class ArgsParser(BareConfig):
         self.defaults = self.get_defaults()
         self.output = self.get_option('output')
 
-        self.parser = OptionParser(
+        self.parser = ArgumentParser(
             usage   = _USAGE)
 
         self.parser.add_argument('-H',


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-15 20:46 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-15 20:46 UTC (permalink / raw
  To: gentoo-commits

commit:     8ff5a7978a1804b786e850a60610b657962052e2
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 23:58:29 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu May 15 20:44:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=8ff5a797

argsparser.py: Migrates from optparse to argparse

Included with this patch is another flag, -C for config dir as well
as default values for configdir, config, and overlay_defs. Also
included is interpolation of these variables, because argparse lacks
the necessary interpolation.

---
 layman/argsparser.py | 363 ++++++++++++++++++++++++++-------------------------
 1 file changed, 184 insertions(+), 179 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index dd1cc85..6e5fee3 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -31,7 +31,7 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
 
 import sys
 
-from optparse import OptionParser, OptionGroup
+from argparse import ArgumentParser
 
 from layman.config import BareConfig
 from layman.constants import OFF
@@ -71,178 +71,182 @@ class ArgsParser(BareConfig):
 
         BareConfig.__init__(self, stdout=stdout, stderr=stderr,
                             stdin=stdin, root=root)
-        if args == None:
-            args = sys.argv
 
         # get a couple BareConfig items
         self.defaults = self.get_defaults()
         self.output = self.get_option('output')
 
-        self.parser = OptionParser(
-            usage   = _USAGE,
-            version = VERSION)
+        self.parser = ArgumentParser(
+            usage   = _USAGE)
 
-        self.parser.add_option('-H',
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
+        self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
-
         #-----------------------------------------------------------------
         # Main Options
 
-        group = OptionGroup(self.parser,
-                            '<Actions>')
-
-        group.add_option('-a',
-                         '--add',
-                         action = 'append',
-                         help = 'Add the given overlay from the cached remote li'
-                         'st to your locally installed overlays.. Specify "ALL" '
-                         'to add all overlays from the remote list.')
-
-        group.add_option('-d',
-                         '--delete',
-                         action = 'append',
-                         help = 'Remove the given overlay from your locally inst'
-                         'alled overlays. Specify "ALL" to remove all overlays')
-
-        group.add_option('-s',
-                         '--sync',
-                         action = 'append',
-                         help = 'Update the specified overlay. Use "ALL" as para'
-                         'meter to synchronize all overlays')
-
-        group.add_option('-i',
-                         '--info',
-                         action = 'append',
-                         help = 'Display information about the specified overlay'
-                         '.')
-
-        group.add_option('-S',
-                         '--sync-all',
-                         action = 'store_true',
-                         help = 'Update all overlays.')
-
-        group.add_option('-L',
-                         '--list',
-                         action = 'store_true',
-                         help = 'List the contents of the remote list.')
-
-        group.add_option('-l',
-                         '--list-local',
-                         action = 'store_true',
-                         help = 'List the locally installed overlays.')
-
-        group.add_option('-f',
-                         '--fetch',
-                         action = 'store_true',
-                         help = 'Fetch a remote list of overlays. This option is'
-                         ' deprecated. The fetch operation will be performed by '
-                         'default when you run sync, sync-all, or list.')
-
-        group.add_option('-n',
-                         '--nofetch',
-                         action = 'store_true',
-                         help = 'Do not fetch a remote list of overlays.')
-
-        group.add_option('-p',
-                         '--priority',
-                         action = 'store',
-                         help = 'Use this with the --add switch to set the prior'
-                         'ity of the added overlay. This will influence the sort'
-                         'ing order of the overlays in the PORTDIR_OVERLAY varia'
-                         'ble.')
-
-        self.parser.add_option_group(group)
+        actions = self.parser.add_argument_group('<Actions>')
+
+        actions.add_argument('-a',
+                             '--add',
+                             action = 'append',
+                             help = 'Add the given overlay from the cached remote li'
+                             'st to your locally installed overlays.. Specify "ALL" '
+                             'to add all overlays from the remote list.')
+
+        actions.add_argument('-d',
+                             '--delete',
+                             action = 'append',
+                             help = 'Remove the given overlay from your locally inst'
+                             'alled overlays. Specify "ALL" to remove all overlays.')
+
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-i',
+                             '--info',
+                             action = 'append',
+                             help = 'Display information about the specified overlay'
+                             '.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
+        actions.add_argument('-L',
+                             '--list',
+                             action = 'store_true',
+                             help = 'List the contents of the remote list.')
+
+        actions.add_argument('-l',
+                             '--list-local',
+                             action = 'store_true',
+                             help = 'List the locally installed overlays.')
+
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
+
+        actions.add_argument('-n',
+                             '--nofetch',
+                             action = 'store_true',
+                             help = 'Do not fetch a remote list of overlays.')
+
+        actions.add_argument('-p',
+                             '--priority',
+                             action = 'store',
+                             help = 'Use this with the --add switch to set the prior'
+                             'ity of the added overlay. This will influence the sort'
+                             'ing order of the overlays in the PORTDIR_OVERLAY varia'
+                             'ble.')
 
         #-----------------------------------------------------------------
         # Additional Options
 
-        group = OptionGroup(self.parser,
-                            '<Path options>')
+        path_opts = self.parser.add_argument_group('<Path options>')
+
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
+
+        path_opts.add_argument('-c',
+                               '--config',
+                               action = 'store',
+                               default = self.defaults['config'],
+                               # Force interpolation (to prevent argparse tracebacks)
+                               help = 'Path to the config file [default: '
+                               '%s].' % (self.defaults['config'] %self.defaults))
 
-        group.add_option('-c',
-                         '--config',
-                         action = 'store',
-                         help = 'Path to the config file [default: ' \
-                         + self.defaults['config'] + '].')
 
-        group.add_option('-O',
-                         '--overlay_defs',
-                         action = 'store',
-                         help = 'Path to aditional overlay.xml files [default: '\
-                         + self.defaults['overlay_defs'] + '].')
 
-        group.add_option('-o',
-                         '--overlays',
-                         action = 'append',
-                         help = 'The list of overlays [default: ' \
-                         + self.defaults['overlays'] + '].')
+        path_opts.add_argument('-O',
+                               '--overlay_defs',
+                               action = 'store',
+                               default = self.defaults['overlay_defs'],
+                               # Force interpolation (to prevent argparse tracebacks)
+                               help = 'Path to aditional overlay.xml files [default: '
+                               '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        self.parser.add_option_group(group)
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         #-----------------------------------------------------------------
         # Output Options
 
-        group = OptionGroup(self.parser,
-                            '<Output options>')
-
-        group.add_option('-v',
-                         '--verbose',
-                         action = 'store_true',
-                         help = 'Increase the amount of output and describe the '
-                         'overlays.')
-
-        group.add_option('-q',
-                         '--quiet',
-                         action = 'store_true',
-                         help = 'Yield no output. Please be careful with this op'
-                         'tion: If the processes spawned by layman when adding o'
-                         'r synchronizing overlays require any input layman will'
-                         ' hang without telling you why. This might happen for e'
-                         'xample if your overlay resides in subversion and the S'
-                         'SL certificate of the server needs acceptance.')
-
-        group.add_option('-N',
-                         '--nocolor',
-                         action = 'store_true',
-                         help = 'Remove color codes from the layman output.')
-
-        group.add_option('-Q',
-                         '--quietness',
-                         action = 'store',
-                         type = 'int',
-                         default = '4',
-                         help = 'Set the level of output (0-4). Default: 4. Once'
-                         ' you set this below 2 the same warning as given for --'
-                         'quiet applies! ')
-
-        group.add_option('-W',
-                         '--width',
-                         action = 'store',
-                         type = 'int',
-                         default = '0',
-                         help = 'Sets the screen width. This setting is usually '
-                         'not required as layman is capable of detecting the '
-                         'available number of columns automatically.')
-
-        group.add_option('-k',
-                         '--nocheck',
-                         action = 'store_true',
-                         help = 'Do not check overlay definitions and do not i'
-                         'ssue a warning if description or contact information'
-                         ' are missing.')
-
-        group.add_option('--debug-level',
-                         action = 'store',
-                         type = 'int',
-                         help = 'A value between 0 and 10. 0 means no debugging '
-                         'messages will be selected, 10 selects all debugging me'
-                         'ssages. Default is "4".')
-
-
-        self.parser.add_option_group(group)
+        out_opts = self.parser.add_argument_group('<Output options>')
+
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
+        out_opts.add_argument('-q',
+                              '--quiet',
+                              action = 'store_true',
+                              help = 'Yield no output. Please be careful with this op'
+                              'tion: If the processes spawned by layman when adding o'
+                              'r synchronizing overlays require any input layman will'
+                              ' hang without telling you why. This might happen for e'
+                              'xample if your overlay resides in subversion and the S'
+                              'SL certificate of the server needs acceptance.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
+
+        out_opts.add_argument('-Q',
+                              '--quietness',
+                              action = 'store',
+                              type = int,
+                              default = 4,
+                              help = 'Set the level of output (0-4). Default: 4. Once'
+                              ' you set this below 2 the same warning as given for --'
+                              'quiet applies!')
+
+        out_opts.add_argument('-W',
+                              '--width',
+                              action = 'store',
+                              type = int,
+                              default = 0,
+                              help = 'Sets the screen width. This setting is usually '
+                              'not required as layman is capable of detecting the '
+                              'available number of columns automatically.')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
+                              action = 'store_true',
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
 
         #-----------------------------------------------------------------
         # Debug Options
@@ -251,45 +255,46 @@ class ArgsParser(BareConfig):
 
         # Parse the command line first since we need to get the config
         # file option.
-        if len(args) == 1:
-            self.output.notice('Usage:%s' % _USAGE)
-            sys.exit(0)
 
-        (self.options, remain_args) = self.parser.parse_args(args)
-        # remain_args starts with something like "bin/layman" ...
-        if len(remain_args) > 1:
-            self.parser.error("ArgsParser(): Unhandled parameters: %s"
-                % ', '.join(('"%s"' % e) for e in remain_args[1:]))
+        # If no flags are present print out usage
+        if len(sys.argv) == 1:
+            self.output.notice('usage:%s' % _USAGE)
+            sys.exit(0)
 
-        # handle debugging
-        #self.output.cli_handle(self.options)
+        self.options = self.parser.parse_args()
+        self.options = vars(self.options)
+        # Applying interpolation of values
+        for v in ['configdir', 'config', 'overlay_defs']:
+            self.options[v] = self.options[v] % self.options
+            self.defaults[v] = self.options[v]
 
-        if (self.options.__dict__.has_key('debug_level') and
-            self.options.__dict__['debug_level']):
-            dbglvl = int(self.options.__dict__['debug_level'])
+        if ('debug_level' in self.options and
+            self.options['debug_level']):
+            dbglvl = int(self.options['debug_level'])
             if dbglvl < 0:
                 dbglvl = 0
             if dbglvl > 10:
                 dbglvl = 10
             self.output.set_debug_level(dbglvl)
 
-        if self.options.__dict__['nocolor']:
+        if self.options['nocolor']:
             self.output.set_colorize(OFF)
 
         # Set only alternate config settings from the options
-        if self.options.__dict__['config'] is not None:
-            self.defaults['config'] = self.options.__dict__['config']
+        if self.options['config'] is not None:
+            self.defaults['config'] = self.options['config']
             self.output.debug('ARGSPARSER: Got config file at ' + \
                 self.defaults['config'], 8)
         else: # fix the config path
             self.defaults['config'] = self.defaults['config'] \
                 % {'configdir': self.defaults['configdir']}
-        if self.options.__dict__['overlay_defs'] is not None:
-            self.defaults['overlay_defs'] = self.options.__dict__['overlay_defs']
+
+        if self.options['overlay_defs'] is not None:
+            self.defaults['overlay_defs'] = self.options['overlay_defs']
             self.output.debug('ARGSPARSER: Got overlay_defs location at ' + \
                 self.defaults['overlay_defs'], 8)
 
-        self._options['setup_help'] = self.options.__dict__['setup_help']
+        self._options['setup_help'] = self.options['setup_help']
 
         # Now parse the config file
         self.output.debug('ARGSPARSER: Reading config file at ' + \
@@ -297,19 +302,19 @@ class ArgsParser(BareConfig):
         self.read_config(self.defaults)
 
         # handle quietness
-        if self.options.__dict__['quiet']:
+        if self.options['quiet']:
             self.set_option('quiet', True)
-        elif self.options.__dict__['quietness']:
-            self.set_option('quietness', self.options.__dict__['quietness'])
+        elif self.options['quietness']:
+            self.set_option('quietness', self.options['quietness'])
 
 
     def __getitem__(self, key):
 
         if key == 'overlays':
             overlays = ''
-            if (key in list(self.options.__dict__.keys())
-                and not self.options.__dict__[key] is None):
-                overlays = '\n'.join(self.options.__dict__[key])
+            if (key in list(self.options.keys())
+                and not self.options[key] is None):
+                overlays = '\n'.join(self.options[key])
             if self.config.has_option('MAIN', 'overlays'):
                 overlays += '\n' + self.config.get('MAIN', 'overlays')
             if len(overlays):
@@ -317,9 +322,9 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving options option: %s' % key, 9)
 
-        if (key in list(self.options.__dict__.keys())
-            and not self.options.__dict__[key] is None):
-            return self.options.__dict__[key]
+        if (key in list(self.options.keys())
+            and not self.options[key] is False):
+            return self.options[key]
 
         self.output.debug('ARGSPARSER: Retrieving config option: %s' % key, 9)
 
@@ -346,8 +351,9 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving keys', 9)
 
-        keys = [i for i in list(self.options.__dict__.keys())
-                if not self.options.__dict__[i] is None]
+        keys = [i for i in list(self.options)
+                if not self.options[i] is False
+                and not self.options[i] is None]
 
         self.output.debug('ARGSPARSER: Retrieving keys 2', 9)
 
@@ -358,7 +364,6 @@ class ArgsParser(BareConfig):
 
         keys += [i for i in list(self.defaults.keys())
                  if not i in keys]
-
         self.output.debug('ARGSPARSER: Returning keys', 9)
 
         return keys


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-15 20:46 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-15 20:46 UTC (permalink / raw
  To: gentoo-commits

commit:     a6c4d787287228573f8cb5150fbf385423832518
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 19:58:36 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu May 15 20:45:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a6c4d787

argsparser.py: Aplhabetizes group arguments

---
 layman/argsparser.py | 114 +++++++++++++++++++++++++--------------------------
 1 file changed, 56 insertions(+), 58 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 6e5fee3..5b94530 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -79,16 +79,16 @@ class ArgsParser(BareConfig):
         self.parser = ArgumentParser(
             usage   = _USAGE)
 
-        self.parser.add_argument('-V',
-                          '--version',
-                          action = 'version',
-                          version = VERSION)
-
         self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
         #-----------------------------------------------------------------
         # Main Options
 
@@ -107,11 +107,12 @@ class ArgsParser(BareConfig):
                              help = 'Remove the given overlay from your locally inst'
                              'alled overlays. Specify "ALL" to remove all overlays.')
 
-        actions.add_argument('-s',
-                             '--sync',
-                             action = 'append',
-                             help = 'Update the specified overlay. Use "ALL" as para'
-                            'meter to synchronize all overlays.')
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
 
         actions.add_argument('-i',
                              '--info',
@@ -119,11 +120,6 @@ class ArgsParser(BareConfig):
                              help = 'Display information about the specified overlay'
                              '.')
 
-        actions.add_argument('-S',
-                             '--sync-all',
-                             action = 'store_true',
-                             help = 'Update all overlays.')
-
         actions.add_argument('-L',
                              '--list',
                              action = 'store_true',
@@ -134,13 +130,6 @@ class ArgsParser(BareConfig):
                              action = 'store_true',
                              help = 'List the locally installed overlays.')
 
-        actions.add_argument('-f',
-                             '--fetch',
-                             action = 'store_true',
-                             help = 'Fetch a remote list of overlays. This option is'
-                             ' deprecated. The fetch operation will be performed by '
-                             'default when you run sync, sync-all, or list.')
-
         actions.add_argument('-n',
                              '--nofetch',
                              action = 'store_true',
@@ -154,18 +143,22 @@ class ArgsParser(BareConfig):
                              'ing order of the overlays in the PORTDIR_OVERLAY varia'
                              'ble.')
 
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
         #-----------------------------------------------------------------
         # Additional Options
 
         path_opts = self.parser.add_argument_group('<Path options>')
 
-        path_opts.add_argument('-C',
-                               '--configdir',
-                               action = 'store',
-                               default = '/etc/layman',
-                               help = 'Directory path to user for all layman configu'
-                               'ration information [default: /etc/layman].')
-
         path_opts.add_argument('-c',
                                '--config',
                                action = 'store',
@@ -174,7 +167,18 @@ class ArgsParser(BareConfig):
                                help = 'Path to the config file [default: '
                                '%s].' % (self.defaults['config'] %self.defaults))
 
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
 
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         path_opts.add_argument('-O',
                                '--overlay_defs',
@@ -184,22 +188,29 @@ class ArgsParser(BareConfig):
                                help = 'Path to aditional overlay.xml files [default: '
                                '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        path_opts.add_argument('-o',
-                               '--overlays',
-                               action = 'append',
-                               help = 'The list of overlays [default: ' \
-                               + self.defaults['overlays'] + '].')
-
         #-----------------------------------------------------------------
         # Output Options
 
         out_opts = self.parser.add_argument_group('<Output options>')
 
-        out_opts.add_argument('-v',
-                              '--verbose',
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
                               action = 'store_true',
-                              help = 'Increase the amount of output and describe the '
-                              'overlays.')
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
 
         out_opts.add_argument('-q',
                               '--quiet',
@@ -211,11 +222,6 @@ class ArgsParser(BareConfig):
                               'xample if your overlay resides in subversion and the S'
                               'SL certificate of the server needs acceptance.')
 
-        out_opts.add_argument('-N',
-                              '--nocolor',
-                              action = 'store_true',
-                              help = 'Remove color codes from the layman output.')
-
         out_opts.add_argument('-Q',
                               '--quietness',
                               action = 'store',
@@ -225,6 +231,12 @@ class ArgsParser(BareConfig):
                               ' you set this below 2 the same warning as given for --'
                               'quiet applies!')
 
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
         out_opts.add_argument('-W',
                               '--width',
                               action = 'store',
@@ -234,20 +246,6 @@ class ArgsParser(BareConfig):
                               'not required as layman is capable of detecting the '
                               'available number of columns automatically.')
 
-        out_opts.add_argument('-k',
-                              '--nocheck',
-                              action = 'store_true',
-                              help = 'Do not check overlay definitions and do not i'
-                              'ssue a warning if description or contact information'
-                              ' are missing.')
-
-        out_opts.add_argument('--debug-level',
-                              action = 'store',
-                              type = int,
-                              help = 'A value between 0 and 10. 0 means no debugging '
-                              'messages will be selected, 10 selects all debugging me'
-                              'ssages. Default is "4".')
-
         #-----------------------------------------------------------------
         # Debug Options
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  0:57 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  0:57 UTC (permalink / raw
  To: gentoo-commits

commit:     83c2ce4a98f6fa0d86e4109203e616fdec796bed
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 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


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  0:58 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  0:58 UTC (permalink / raw
  To: gentoo-commits

commit:     77d5a73e47657bc551fb98cf6332f7601439a47a
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 19:58:36 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri May 16 00:58:14 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=77d5a73e

argsparser.py: Alphabetizes group arguments

---
 layman/argsparser.py | 114 +++++++++++++++++++++++++--------------------------
 1 file changed, 56 insertions(+), 58 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 6e5fee3..5b94530 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -79,16 +79,16 @@ class ArgsParser(BareConfig):
         self.parser = ArgumentParser(
             usage   = _USAGE)
 
-        self.parser.add_argument('-V',
-                          '--version',
-                          action = 'version',
-                          version = VERSION)
-
         self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
         #-----------------------------------------------------------------
         # Main Options
 
@@ -107,11 +107,12 @@ class ArgsParser(BareConfig):
                              help = 'Remove the given overlay from your locally inst'
                              'alled overlays. Specify "ALL" to remove all overlays.')
 
-        actions.add_argument('-s',
-                             '--sync',
-                             action = 'append',
-                             help = 'Update the specified overlay. Use "ALL" as para'
-                            'meter to synchronize all overlays.')
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
 
         actions.add_argument('-i',
                              '--info',
@@ -119,11 +120,6 @@ class ArgsParser(BareConfig):
                              help = 'Display information about the specified overlay'
                              '.')
 
-        actions.add_argument('-S',
-                             '--sync-all',
-                             action = 'store_true',
-                             help = 'Update all overlays.')
-
         actions.add_argument('-L',
                              '--list',
                              action = 'store_true',
@@ -134,13 +130,6 @@ class ArgsParser(BareConfig):
                              action = 'store_true',
                              help = 'List the locally installed overlays.')
 
-        actions.add_argument('-f',
-                             '--fetch',
-                             action = 'store_true',
-                             help = 'Fetch a remote list of overlays. This option is'
-                             ' deprecated. The fetch operation will be performed by '
-                             'default when you run sync, sync-all, or list.')
-
         actions.add_argument('-n',
                              '--nofetch',
                              action = 'store_true',
@@ -154,18 +143,22 @@ class ArgsParser(BareConfig):
                              'ing order of the overlays in the PORTDIR_OVERLAY varia'
                              'ble.')
 
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
         #-----------------------------------------------------------------
         # Additional Options
 
         path_opts = self.parser.add_argument_group('<Path options>')
 
-        path_opts.add_argument('-C',
-                               '--configdir',
-                               action = 'store',
-                               default = '/etc/layman',
-                               help = 'Directory path to user for all layman configu'
-                               'ration information [default: /etc/layman].')
-
         path_opts.add_argument('-c',
                                '--config',
                                action = 'store',
@@ -174,7 +167,18 @@ class ArgsParser(BareConfig):
                                help = 'Path to the config file [default: '
                                '%s].' % (self.defaults['config'] %self.defaults))
 
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
 
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         path_opts.add_argument('-O',
                                '--overlay_defs',
@@ -184,22 +188,29 @@ class ArgsParser(BareConfig):
                                help = 'Path to aditional overlay.xml files [default: '
                                '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        path_opts.add_argument('-o',
-                               '--overlays',
-                               action = 'append',
-                               help = 'The list of overlays [default: ' \
-                               + self.defaults['overlays'] + '].')
-
         #-----------------------------------------------------------------
         # Output Options
 
         out_opts = self.parser.add_argument_group('<Output options>')
 
-        out_opts.add_argument('-v',
-                              '--verbose',
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
                               action = 'store_true',
-                              help = 'Increase the amount of output and describe the '
-                              'overlays.')
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
 
         out_opts.add_argument('-q',
                               '--quiet',
@@ -211,11 +222,6 @@ class ArgsParser(BareConfig):
                               'xample if your overlay resides in subversion and the S'
                               'SL certificate of the server needs acceptance.')
 
-        out_opts.add_argument('-N',
-                              '--nocolor',
-                              action = 'store_true',
-                              help = 'Remove color codes from the layman output.')
-
         out_opts.add_argument('-Q',
                               '--quietness',
                               action = 'store',
@@ -225,6 +231,12 @@ class ArgsParser(BareConfig):
                               ' you set this below 2 the same warning as given for --'
                               'quiet applies!')
 
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
         out_opts.add_argument('-W',
                               '--width',
                               action = 'store',
@@ -234,20 +246,6 @@ class ArgsParser(BareConfig):
                               'not required as layman is capable of detecting the '
                               'available number of columns automatically.')
 
-        out_opts.add_argument('-k',
-                              '--nocheck',
-                              action = 'store_true',
-                              help = 'Do not check overlay definitions and do not i'
-                              'ssue a warning if description or contact information'
-                              ' are missing.')
-
-        out_opts.add_argument('--debug-level',
-                              action = 'store',
-                              type = int,
-                              help = 'A value between 0 and 10. 0 means no debugging '
-                              'messages will be selected, 10 selects all debugging me'
-                              'ssages. Default is "4".')
-
         #-----------------------------------------------------------------
         # Debug Options
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  0:58 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  0:58 UTC (permalink / raw
  To: gentoo-commits

commit:     6e99229397a9f051fb5e68d17659cd0fe5fb062f
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 00:58:20 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6e992293

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


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     ab72f75040baecdf9573cce40c2b896cb96379b9
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 20:56:23 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri May 16 01:06:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ab72f750

layman/config.py: Adds py3 compatibility for ConfigParser

---
 layman/config.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/layman/config.py b/layman/config.py
index bf33f50..0827b71 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -28,7 +28,14 @@ __version__ = "0.2"
 
 import sys
 import os
-import ConfigParser
+
+try:
+    # Import for Python3
+    import configparser as ConfigParser
+    from configparser import BasicInterpolation
+except:
+    # Import for Python2
+    import ConfigParser
 
 from layman.output import Message
 from layman.utils import path
@@ -247,6 +254,7 @@ class BareConfig(object):
                 return  overlays
         if (key in self._options
             and not self._options[key] is None):
+            self._options['config'] = '/etc/layman/layman.cfg'
             return self._options[key]
         if self.config and self.config.has_option('MAIN', key):
             if key in self._defaults['t/f_options']:


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     e21d636e07a1f6875ae916b87a4cb8c23f0de6cf
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:10:50 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=e21d636e

dbbase.py: Adds unicode compatibility to ElementTree

When writing the database to installed.xml, ElementTree needs to have
an encoding type specified or run time errors will occur. To ensure
compatibility between py2/py3 a check has been made to see which
python version is running and to set the _unicode variable
accordingly.

---
 layman/dbbase.py | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index ff99965..3632a57 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -37,6 +37,14 @@ from   layman.utils              import indent
 from   layman.compatibility      import fileopen
 from   layman.overlays.overlay   import Overlay
 
+#py3.2
+if sys.hexversion >= 0x30200f0:
+    _unicode = 'unicode'
+else:
+    _unicode = 'UTF-8'
+
+
+
 #===============================================================================
 #
 # Class UnknownOverlayException
@@ -220,16 +228,13 @@ class DbBase(object):
         >>> os.rmdir(tmpdir)
         '''
 
-        tree = ET.Element('repositories', version="1.0")
+        tree = ET.Element('repositories', version="1.0", encoding="unicode")
         tree[:] = [e.to_xml() for e in list(self.overlays.values())]
         indent(tree)
         tree = ET.ElementTree(tree)
         try:
             f = fileopen(path, 'w')
-            f.write("""\
-<?xml version="1.0" encoding="UTF-8"?>
-""")
-            tree.write(f, encoding='utf-8')
+            tree.write(f, encoding=_unicode)
             f.close()
         except Exception as error:
             raise Exception('Failed to write to local overlays file: '


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     f4f8b47f13fdf016a2dde788f496322446b407cc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:28:10 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=f4f8b47f

layman/makeconf.py: Implements cmp_to_key on prio_sort

To ensure py2/py3 compat, the cmp_to_key function has been used to
the convert the variable prio_sort to a key instead of a comparison
like py3 returns prio_sort to be.

---
 layman/makeconf.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/layman/makeconf.py b/layman/makeconf.py
index b592fc0..d8f0015 100644
--- a/layman/makeconf.py
+++ b/layman/makeconf.py
@@ -20,6 +20,7 @@ import codecs
 import re
 
 from layman.utils import path
+from layman.compatibility import cmp_to_key
 
 #===============================================================================
 #
@@ -246,7 +247,7 @@ class MakeConf:
                 return 1
             return 0
 
-        self.overlays.sort(prio_sort)
+        self.overlays.sort(key=cmp_to_key(prio_sort))
 
         paths = []
         for i in self.overlays:


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     6cf1b5626a81d9bfbf4ad4125df9719760144837
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 19:24:59 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri May 16 01:05:56 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6cf1b562

layman/api.py: Corrects output of repos and stderr

Due to repos coming in as a binary string, it needed to be converted
to a normal string before joining it in the debug message or it will
cause runtime failures. Due to 2to3 overlooking the print statement
on line 513, this has also been corrected along with a check to see if
the repos variable is an instance of type str instead of type basestring
which is no longer available in py3.

---
 layman/api.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index f36be0a..7dd5ea7 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -90,7 +90,7 @@ class LaymanAPI(object):
         converting a string to a list[string] if it is not already a list.
         produces and error message if it is any other type
         returns repos as list always"""
-        if isinstance(repos, basestring):
+        if isinstance(repos, str):
             repos = [repos]
         # else assume it is an iterable, if not it will error
         return [encode(i) for i in repos]
@@ -299,7 +299,7 @@ class LaymanAPI(object):
         @param update_news: bool, defaults to False
         @rtype bool or {'repo-id': bool,...}
         """
-        self.output.debug("API.sync(); repos to sync = %s" % ', '.join(repos), 5)
+        self.output.debug("API.sync(); repos to sync = %s" % ', '.join((x.decode() if isinstance(x, bytes) else x) for x in repos), 5)
         fatals = []
         warnings = []
         success  = []
@@ -513,7 +513,7 @@ class LaymanAPI(object):
         self._error_messages.append(message)
         self.output.debug("API._error(); _error_messages = %s" % str(self._error_messages), 4)
         if self.report_errors:
-            print >>self.config['stderr'], message
+            print(message, file=self.config['stderr'])
 
 
     def get_errors(self):


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

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


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     640d8976db67de37c90bf752c090ce8e2e659e00
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:01 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=640d8976

utils.py: Adds str type checking for path_elements

---
 layman/utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/utils.py b/layman/utils.py
index efb3231..bc8f473 100644
--- a/layman/utils.py
+++ b/layman/utils.py
@@ -149,7 +149,7 @@ def path(path_elements):
     '''
     pathname = ''
 
-    if type(path_elements) in types.StringTypes:
+    if isinstance(path_elements, str):
         path_elements = [path_elements]
 
     # Concatenate elements and seperate with /


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     492e7bb8c6591c0fd5105c750612b1d6dc918403
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 23:58:29 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=492e7bb8

argsparser.py: Migrates from optparse to argparse

Included with this patch is another flag, -C for config dir as well
as default values for configdir, config, and overlay_defs. Also
included is interpolation of these variables, because argparse lacks
the necessary interpolation.

---
 layman/argsparser.py | 363 ++++++++++++++++++++++++++-------------------------
 1 file changed, 184 insertions(+), 179 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index dd1cc85..6e5fee3 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -31,7 +31,7 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
 
 import sys
 
-from optparse import OptionParser, OptionGroup
+from argparse import ArgumentParser
 
 from layman.config import BareConfig
 from layman.constants import OFF
@@ -71,178 +71,182 @@ class ArgsParser(BareConfig):
 
         BareConfig.__init__(self, stdout=stdout, stderr=stderr,
                             stdin=stdin, root=root)
-        if args == None:
-            args = sys.argv
 
         # get a couple BareConfig items
         self.defaults = self.get_defaults()
         self.output = self.get_option('output')
 
-        self.parser = OptionParser(
-            usage   = _USAGE,
-            version = VERSION)
+        self.parser = ArgumentParser(
+            usage   = _USAGE)
 
-        self.parser.add_option('-H',
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
+        self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
-
         #-----------------------------------------------------------------
         # Main Options
 
-        group = OptionGroup(self.parser,
-                            '<Actions>')
-
-        group.add_option('-a',
-                         '--add',
-                         action = 'append',
-                         help = 'Add the given overlay from the cached remote li'
-                         'st to your locally installed overlays.. Specify "ALL" '
-                         'to add all overlays from the remote list.')
-
-        group.add_option('-d',
-                         '--delete',
-                         action = 'append',
-                         help = 'Remove the given overlay from your locally inst'
-                         'alled overlays. Specify "ALL" to remove all overlays')
-
-        group.add_option('-s',
-                         '--sync',
-                         action = 'append',
-                         help = 'Update the specified overlay. Use "ALL" as para'
-                         'meter to synchronize all overlays')
-
-        group.add_option('-i',
-                         '--info',
-                         action = 'append',
-                         help = 'Display information about the specified overlay'
-                         '.')
-
-        group.add_option('-S',
-                         '--sync-all',
-                         action = 'store_true',
-                         help = 'Update all overlays.')
-
-        group.add_option('-L',
-                         '--list',
-                         action = 'store_true',
-                         help = 'List the contents of the remote list.')
-
-        group.add_option('-l',
-                         '--list-local',
-                         action = 'store_true',
-                         help = 'List the locally installed overlays.')
-
-        group.add_option('-f',
-                         '--fetch',
-                         action = 'store_true',
-                         help = 'Fetch a remote list of overlays. This option is'
-                         ' deprecated. The fetch operation will be performed by '
-                         'default when you run sync, sync-all, or list.')
-
-        group.add_option('-n',
-                         '--nofetch',
-                         action = 'store_true',
-                         help = 'Do not fetch a remote list of overlays.')
-
-        group.add_option('-p',
-                         '--priority',
-                         action = 'store',
-                         help = 'Use this with the --add switch to set the prior'
-                         'ity of the added overlay. This will influence the sort'
-                         'ing order of the overlays in the PORTDIR_OVERLAY varia'
-                         'ble.')
-
-        self.parser.add_option_group(group)
+        actions = self.parser.add_argument_group('<Actions>')
+
+        actions.add_argument('-a',
+                             '--add',
+                             action = 'append',
+                             help = 'Add the given overlay from the cached remote li'
+                             'st to your locally installed overlays.. Specify "ALL" '
+                             'to add all overlays from the remote list.')
+
+        actions.add_argument('-d',
+                             '--delete',
+                             action = 'append',
+                             help = 'Remove the given overlay from your locally inst'
+                             'alled overlays. Specify "ALL" to remove all overlays.')
+
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-i',
+                             '--info',
+                             action = 'append',
+                             help = 'Display information about the specified overlay'
+                             '.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
+        actions.add_argument('-L',
+                             '--list',
+                             action = 'store_true',
+                             help = 'List the contents of the remote list.')
+
+        actions.add_argument('-l',
+                             '--list-local',
+                             action = 'store_true',
+                             help = 'List the locally installed overlays.')
+
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
+
+        actions.add_argument('-n',
+                             '--nofetch',
+                             action = 'store_true',
+                             help = 'Do not fetch a remote list of overlays.')
+
+        actions.add_argument('-p',
+                             '--priority',
+                             action = 'store',
+                             help = 'Use this with the --add switch to set the prior'
+                             'ity of the added overlay. This will influence the sort'
+                             'ing order of the overlays in the PORTDIR_OVERLAY varia'
+                             'ble.')
 
         #-----------------------------------------------------------------
         # Additional Options
 
-        group = OptionGroup(self.parser,
-                            '<Path options>')
+        path_opts = self.parser.add_argument_group('<Path options>')
+
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
+
+        path_opts.add_argument('-c',
+                               '--config',
+                               action = 'store',
+                               default = self.defaults['config'],
+                               # Force interpolation (to prevent argparse tracebacks)
+                               help = 'Path to the config file [default: '
+                               '%s].' % (self.defaults['config'] %self.defaults))
 
-        group.add_option('-c',
-                         '--config',
-                         action = 'store',
-                         help = 'Path to the config file [default: ' \
-                         + self.defaults['config'] + '].')
 
-        group.add_option('-O',
-                         '--overlay_defs',
-                         action = 'store',
-                         help = 'Path to aditional overlay.xml files [default: '\
-                         + self.defaults['overlay_defs'] + '].')
 
-        group.add_option('-o',
-                         '--overlays',
-                         action = 'append',
-                         help = 'The list of overlays [default: ' \
-                         + self.defaults['overlays'] + '].')
+        path_opts.add_argument('-O',
+                               '--overlay_defs',
+                               action = 'store',
+                               default = self.defaults['overlay_defs'],
+                               # Force interpolation (to prevent argparse tracebacks)
+                               help = 'Path to aditional overlay.xml files [default: '
+                               '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        self.parser.add_option_group(group)
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         #-----------------------------------------------------------------
         # Output Options
 
-        group = OptionGroup(self.parser,
-                            '<Output options>')
-
-        group.add_option('-v',
-                         '--verbose',
-                         action = 'store_true',
-                         help = 'Increase the amount of output and describe the '
-                         'overlays.')
-
-        group.add_option('-q',
-                         '--quiet',
-                         action = 'store_true',
-                         help = 'Yield no output. Please be careful with this op'
-                         'tion: If the processes spawned by layman when adding o'
-                         'r synchronizing overlays require any input layman will'
-                         ' hang without telling you why. This might happen for e'
-                         'xample if your overlay resides in subversion and the S'
-                         'SL certificate of the server needs acceptance.')
-
-        group.add_option('-N',
-                         '--nocolor',
-                         action = 'store_true',
-                         help = 'Remove color codes from the layman output.')
-
-        group.add_option('-Q',
-                         '--quietness',
-                         action = 'store',
-                         type = 'int',
-                         default = '4',
-                         help = 'Set the level of output (0-4). Default: 4. Once'
-                         ' you set this below 2 the same warning as given for --'
-                         'quiet applies! ')
-
-        group.add_option('-W',
-                         '--width',
-                         action = 'store',
-                         type = 'int',
-                         default = '0',
-                         help = 'Sets the screen width. This setting is usually '
-                         'not required as layman is capable of detecting the '
-                         'available number of columns automatically.')
-
-        group.add_option('-k',
-                         '--nocheck',
-                         action = 'store_true',
-                         help = 'Do not check overlay definitions and do not i'
-                         'ssue a warning if description or contact information'
-                         ' are missing.')
-
-        group.add_option('--debug-level',
-                         action = 'store',
-                         type = 'int',
-                         help = 'A value between 0 and 10. 0 means no debugging '
-                         'messages will be selected, 10 selects all debugging me'
-                         'ssages. Default is "4".')
-
-
-        self.parser.add_option_group(group)
+        out_opts = self.parser.add_argument_group('<Output options>')
+
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
+        out_opts.add_argument('-q',
+                              '--quiet',
+                              action = 'store_true',
+                              help = 'Yield no output. Please be careful with this op'
+                              'tion: If the processes spawned by layman when adding o'
+                              'r synchronizing overlays require any input layman will'
+                              ' hang without telling you why. This might happen for e'
+                              'xample if your overlay resides in subversion and the S'
+                              'SL certificate of the server needs acceptance.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
+
+        out_opts.add_argument('-Q',
+                              '--quietness',
+                              action = 'store',
+                              type = int,
+                              default = 4,
+                              help = 'Set the level of output (0-4). Default: 4. Once'
+                              ' you set this below 2 the same warning as given for --'
+                              'quiet applies!')
+
+        out_opts.add_argument('-W',
+                              '--width',
+                              action = 'store',
+                              type = int,
+                              default = 0,
+                              help = 'Sets the screen width. This setting is usually '
+                              'not required as layman is capable of detecting the '
+                              'available number of columns automatically.')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
+                              action = 'store_true',
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
 
         #-----------------------------------------------------------------
         # Debug Options
@@ -251,45 +255,46 @@ class ArgsParser(BareConfig):
 
         # Parse the command line first since we need to get the config
         # file option.
-        if len(args) == 1:
-            self.output.notice('Usage:%s' % _USAGE)
-            sys.exit(0)
 
-        (self.options, remain_args) = self.parser.parse_args(args)
-        # remain_args starts with something like "bin/layman" ...
-        if len(remain_args) > 1:
-            self.parser.error("ArgsParser(): Unhandled parameters: %s"
-                % ', '.join(('"%s"' % e) for e in remain_args[1:]))
+        # If no flags are present print out usage
+        if len(sys.argv) == 1:
+            self.output.notice('usage:%s' % _USAGE)
+            sys.exit(0)
 
-        # handle debugging
-        #self.output.cli_handle(self.options)
+        self.options = self.parser.parse_args()
+        self.options = vars(self.options)
+        # Applying interpolation of values
+        for v in ['configdir', 'config', 'overlay_defs']:
+            self.options[v] = self.options[v] % self.options
+            self.defaults[v] = self.options[v]
 
-        if (self.options.__dict__.has_key('debug_level') and
-            self.options.__dict__['debug_level']):
-            dbglvl = int(self.options.__dict__['debug_level'])
+        if ('debug_level' in self.options and
+            self.options['debug_level']):
+            dbglvl = int(self.options['debug_level'])
             if dbglvl < 0:
                 dbglvl = 0
             if dbglvl > 10:
                 dbglvl = 10
             self.output.set_debug_level(dbglvl)
 
-        if self.options.__dict__['nocolor']:
+        if self.options['nocolor']:
             self.output.set_colorize(OFF)
 
         # Set only alternate config settings from the options
-        if self.options.__dict__['config'] is not None:
-            self.defaults['config'] = self.options.__dict__['config']
+        if self.options['config'] is not None:
+            self.defaults['config'] = self.options['config']
             self.output.debug('ARGSPARSER: Got config file at ' + \
                 self.defaults['config'], 8)
         else: # fix the config path
             self.defaults['config'] = self.defaults['config'] \
                 % {'configdir': self.defaults['configdir']}
-        if self.options.__dict__['overlay_defs'] is not None:
-            self.defaults['overlay_defs'] = self.options.__dict__['overlay_defs']
+
+        if self.options['overlay_defs'] is not None:
+            self.defaults['overlay_defs'] = self.options['overlay_defs']
             self.output.debug('ARGSPARSER: Got overlay_defs location at ' + \
                 self.defaults['overlay_defs'], 8)
 
-        self._options['setup_help'] = self.options.__dict__['setup_help']
+        self._options['setup_help'] = self.options['setup_help']
 
         # Now parse the config file
         self.output.debug('ARGSPARSER: Reading config file at ' + \
@@ -297,19 +302,19 @@ class ArgsParser(BareConfig):
         self.read_config(self.defaults)
 
         # handle quietness
-        if self.options.__dict__['quiet']:
+        if self.options['quiet']:
             self.set_option('quiet', True)
-        elif self.options.__dict__['quietness']:
-            self.set_option('quietness', self.options.__dict__['quietness'])
+        elif self.options['quietness']:
+            self.set_option('quietness', self.options['quietness'])
 
 
     def __getitem__(self, key):
 
         if key == 'overlays':
             overlays = ''
-            if (key in list(self.options.__dict__.keys())
-                and not self.options.__dict__[key] is None):
-                overlays = '\n'.join(self.options.__dict__[key])
+            if (key in list(self.options.keys())
+                and not self.options[key] is None):
+                overlays = '\n'.join(self.options[key])
             if self.config.has_option('MAIN', 'overlays'):
                 overlays += '\n' + self.config.get('MAIN', 'overlays')
             if len(overlays):
@@ -317,9 +322,9 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving options option: %s' % key, 9)
 
-        if (key in list(self.options.__dict__.keys())
-            and not self.options.__dict__[key] is None):
-            return self.options.__dict__[key]
+        if (key in list(self.options.keys())
+            and not self.options[key] is False):
+            return self.options[key]
 
         self.output.debug('ARGSPARSER: Retrieving config option: %s' % key, 9)
 
@@ -346,8 +351,9 @@ class ArgsParser(BareConfig):
 
         self.output.debug('ARGSPARSER: Retrieving keys', 9)
 
-        keys = [i for i in list(self.options.__dict__.keys())
-                if not self.options.__dict__[i] is None]
+        keys = [i for i in list(self.options)
+                if not self.options[i] is False
+                and not self.options[i] is None]
 
         self.output.debug('ARGSPARSER: Retrieving keys 2', 9)
 
@@ -358,7 +364,6 @@ class ArgsParser(BareConfig):
 
         keys += [i for i in list(self.defaults.keys())
                  if not i in keys]
-
         self.output.debug('ARGSPARSER: Returning keys', 9)
 
         return keys


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     c7a27f6eb028ef5aedfa3145f9db921ff47d0f50
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 23:52:23 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=c7a27f6e

dbbase.py: Fixes implicit tuple unpacking

A temporary variable is assigned to fix the lack of implicit tuple
unpacking in py3.

---
 layman/dbbase.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/dbbase.py b/layman/dbbase.py
index 3632a57..1cbf0bb 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -312,7 +312,7 @@ class DbBase(object):
                 result.append((overlay.short_list(width), overlay.is_supported(),
                                overlay.is_official()))
 
-        result = sorted(result, key=lambda (summary, supported, official): summary.lower())
+        result = sorted(result, key=lambda summary_supported_official: summary_supported_official[0].lower())
 
         return result
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     77fa5d8cd3ead77a9fb03ced890a874d98f9e604
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 22:08:45 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=77fa5d8c

layman/cli.py: Adds byte array support

When checking the selection of which servers to sync/add there is
a check to see if 'ALL' is specified. In py2 with argparser this
works, but with py3 and argparser, this doesn't work because the
'ALL' string will come in as a bytearray. This commit fixes that
by checking the python version and assigning a varaible to be checked
instead of a simple string like 'ALL'. It will now come in as either
'ALL' or b'ALL', py version dependent. A small fix is also made to
docstring to make the print function py3 compatibile.

---
 layman/cli.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/layman/cli.py b/layman/cli.py
index cccddc6..460114a 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -30,7 +30,10 @@ from layman.utils import (decode_selection, encoder, get_encoding,
 from layman.constants import (NOT_OFFICIAL_MSG, NOT_SUPPORTED_MSG,
     FAILURE, SUCCEED)
 
-
+if sys.hexversion >= 0x30200f0:
+    ALL_KEYWORD = b'ALL'
+else:
+    ALL_KEYWORD = 'ALL'
 
 class ListPrinter(object):
     def __init__(self, config):
@@ -103,7 +106,7 @@ class ListPrinter(object):
 
     def short_list(self, overlay):
         '''
-        >>> print short_list(overlay)
+        >>> print(short_list(overlay))
         wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
         '''
         name   = pad(overlay['name'], 25)
@@ -184,7 +187,6 @@ class Main(object):
         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()):
@@ -234,13 +236,14 @@ class Main(object):
         '''
         self.output.info("Adding overlay,...", 2)
         selection = decode_selection(self.config['add'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
+            selection = str(selection)
             selection = self.api.get_available()
         self.output.debug('Adding selected overlays', 6)
         result = self.api.add_repos(selection, update_news=True)
         if result:
-            self.output.info('Successfully added overlay(s) '+\
-                ', '.join(selection) +'.', 2)
+            selection = b', '.join(selection)
+            self.output.info('Successfully added overlay(s) '+ selection.decode('UTF-8') +'.', 2)
         # blank newline  -- no " *"
         self.output.notice('')
         return result
@@ -253,7 +256,7 @@ class Main(object):
         self.output.info("Syncing selected overlays,...", 2)
         # Note api.sync() defaults to printing results
         selection = decode_selection(self.config['sync'])
-        if self.config['sync_all'] or 'ALL' in selection:
+        if self.config['sync_all'] or ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         self.output.debug('Updating selected overlays', 6)
         result = self.api.sync(selection, update_news=True)
@@ -267,7 +270,7 @@ class Main(object):
         '''
         self.output.info('Deleting selected overlays,...', 2)
         selection = decode_selection(self.config['delete'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_installed()
         result = self.api.delete_repos(selection)
         if result:
@@ -282,7 +285,7 @@ class Main(object):
         ''' Print information about the specified overlays.
         '''
         selection = decode_selection(self.config['info'])
-        if 'ALL' in selection:
+        if ALL_KEYWORD in selection:
             selection = self.api.get_available()
 
         list_printer = ListPrinter(self.config)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     0288fec4f81cb307666d481c54e9ffa968e3f878
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 15 19:58:36 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=0288fec4

argsparser.py: Alphabetizes group arguments

---
 layman/argsparser.py | 114 +++++++++++++++++++++++++--------------------------
 1 file changed, 56 insertions(+), 58 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 6e5fee3..5b94530 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -79,16 +79,16 @@ class ArgsParser(BareConfig):
         self.parser = ArgumentParser(
             usage   = _USAGE)
 
-        self.parser.add_argument('-V',
-                          '--version',
-                          action = 'version',
-                          version = VERSION)
-
         self.parser.add_argument('-H',
                         '--setup_help',
                         action = 'store_true',
                         help = 'Print the NEW INSTALL help messages.')
 
+        self.parser.add_argument('-V',
+                          '--version',
+                          action = 'version',
+                          version = VERSION)
+
         #-----------------------------------------------------------------
         # Main Options
 
@@ -107,11 +107,12 @@ class ArgsParser(BareConfig):
                              help = 'Remove the given overlay from your locally inst'
                              'alled overlays. Specify "ALL" to remove all overlays.')
 
-        actions.add_argument('-s',
-                             '--sync',
-                             action = 'append',
-                             help = 'Update the specified overlay. Use "ALL" as para'
-                            'meter to synchronize all overlays.')
+        actions.add_argument('-f',
+                             '--fetch',
+                             action = 'store_true',
+                             help = 'Fetch a remote list of overlays. This option is'
+                             ' deprecated. The fetch operation will be performed by '
+                             'default when you run sync, sync-all, or list.')
 
         actions.add_argument('-i',
                              '--info',
@@ -119,11 +120,6 @@ class ArgsParser(BareConfig):
                              help = 'Display information about the specified overlay'
                              '.')
 
-        actions.add_argument('-S',
-                             '--sync-all',
-                             action = 'store_true',
-                             help = 'Update all overlays.')
-
         actions.add_argument('-L',
                              '--list',
                              action = 'store_true',
@@ -134,13 +130,6 @@ class ArgsParser(BareConfig):
                              action = 'store_true',
                              help = 'List the locally installed overlays.')
 
-        actions.add_argument('-f',
-                             '--fetch',
-                             action = 'store_true',
-                             help = 'Fetch a remote list of overlays. This option is'
-                             ' deprecated. The fetch operation will be performed by '
-                             'default when you run sync, sync-all, or list.')
-
         actions.add_argument('-n',
                              '--nofetch',
                              action = 'store_true',
@@ -154,18 +143,22 @@ class ArgsParser(BareConfig):
                              'ing order of the overlays in the PORTDIR_OVERLAY varia'
                              'ble.')
 
+        actions.add_argument('-s',
+                             '--sync',
+                             action = 'append',
+                             help = 'Update the specified overlay. Use "ALL" as para'
+                            'meter to synchronize all overlays.')
+
+        actions.add_argument('-S',
+                             '--sync-all',
+                             action = 'store_true',
+                             help = 'Update all overlays.')
+
         #-----------------------------------------------------------------
         # Additional Options
 
         path_opts = self.parser.add_argument_group('<Path options>')
 
-        path_opts.add_argument('-C',
-                               '--configdir',
-                               action = 'store',
-                               default = '/etc/layman',
-                               help = 'Directory path to user for all layman configu'
-                               'ration information [default: /etc/layman].')
-
         path_opts.add_argument('-c',
                                '--config',
                                action = 'store',
@@ -174,7 +167,18 @@ class ArgsParser(BareConfig):
                                help = 'Path to the config file [default: '
                                '%s].' % (self.defaults['config'] %self.defaults))
 
+        path_opts.add_argument('-C',
+                               '--configdir',
+                               action = 'store',
+                               default = '/etc/layman',
+                               help = 'Directory path to user for all layman configu'
+                               'ration information [default: /etc/layman].')
 
+        path_opts.add_argument('-o',
+                               '--overlays',
+                               action = 'append',
+                               help = 'The list of overlays [default: ' \
+                               + self.defaults['overlays'] + '].')
 
         path_opts.add_argument('-O',
                                '--overlay_defs',
@@ -184,22 +188,29 @@ class ArgsParser(BareConfig):
                                help = 'Path to aditional overlay.xml files [default: '
                                '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
-        path_opts.add_argument('-o',
-                               '--overlays',
-                               action = 'append',
-                               help = 'The list of overlays [default: ' \
-                               + self.defaults['overlays'] + '].')
-
         #-----------------------------------------------------------------
         # Output Options
 
         out_opts = self.parser.add_argument_group('<Output options>')
 
-        out_opts.add_argument('-v',
-                              '--verbose',
+        out_opts.add_argument('--debug-level',
+                              action = 'store',
+                              type = int,
+                              help = 'A value between 0 and 10. 0 means no debugging '
+                              'messages will be selected, 10 selects all debugging me'
+                              'ssages. Default is "4".')
+
+        out_opts.add_argument('-k',
+                              '--nocheck',
                               action = 'store_true',
-                              help = 'Increase the amount of output and describe the '
-                              'overlays.')
+                              help = 'Do not check overlay definitions and do not i'
+                              'ssue a warning if description or contact information'
+                              ' are missing.')
+
+        out_opts.add_argument('-N',
+                              '--nocolor',
+                              action = 'store_true',
+                              help = 'Remove color codes from the layman output.')
 
         out_opts.add_argument('-q',
                               '--quiet',
@@ -211,11 +222,6 @@ class ArgsParser(BareConfig):
                               'xample if your overlay resides in subversion and the S'
                               'SL certificate of the server needs acceptance.')
 
-        out_opts.add_argument('-N',
-                              '--nocolor',
-                              action = 'store_true',
-                              help = 'Remove color codes from the layman output.')
-
         out_opts.add_argument('-Q',
                               '--quietness',
                               action = 'store',
@@ -225,6 +231,12 @@ class ArgsParser(BareConfig):
                               ' you set this below 2 the same warning as given for --'
                               'quiet applies!')
 
+        out_opts.add_argument('-v',
+                              '--verbose',
+                              action = 'store_true',
+                              help = 'Increase the amount of output and describe the '
+                              'overlays.')
+
         out_opts.add_argument('-W',
                               '--width',
                               action = 'store',
@@ -234,20 +246,6 @@ class ArgsParser(BareConfig):
                               'not required as layman is capable of detecting the '
                               'available number of columns automatically.')
 
-        out_opts.add_argument('-k',
-                              '--nocheck',
-                              action = 'store_true',
-                              help = 'Do not check overlay definitions and do not i'
-                              'ssue a warning if description or contact information'
-                              ' are missing.')
-
-        out_opts.add_argument('--debug-level',
-                              action = 'store',
-                              type = int,
-                              help = 'A value between 0 and 10. 0 means no debugging '
-                              'messages will be selected, 10 selects all debugging me'
-                              'ssages. Default is "4".')
-
         #-----------------------------------------------------------------
         # Debug Options
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  1:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  1:07 UTC (permalink / raw
  To: gentoo-commits

commit:     aeeafa69ce34887dabf5175fcae52adc62580233
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed May 14 21:33:55 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=aeeafa69

layman/output.py: Adds file output compatibility

In order to allow users to set the output for error and normal
output we need to check to see if users have set the output to be
of type file. In py2 this is specified by the variable "file",
however in py3 this is specified by io.IOBase which encompasses
all file types such as Raw, Text, and Buffered files.

---
 layman/output.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/layman/output.py b/layman/output.py
index ea98894..ef348f5 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -6,6 +6,7 @@
  Distributed under the terms of the GNU General Public License v2
 """
 
+from __future__ import print_function
 
 __version__ = "0.1"
 
@@ -15,6 +16,11 @@ import sys
 from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, NOTE_LEVEL, DEBUG_LEVEL, OFF
 from layman.compatibility import encode
 
+# py3.2
+if sys.hexversion >= 0x30200f0:
+    from io import IOBase as BUILTIN_FILE_TYPE
+else:
+    BUILTIN_FILE_TYPE=file
 
 class MessageBase(object):
     """Base Message class helper functions and variables
@@ -30,13 +36,13 @@ class MessageBase(object):
                  error_callback=None
                  ):
         # Where should the error output go? This can also be a file
-        if isinstance(err, file):
+        if isinstance(err, BUILTIN_FILE_TYPE):
             self.error_out = err
         else:
             raise Exception("MessageBase: input parameter 'err' must be of type: file")
 
         # Where should the normal output go? This can also be a file
-        if isinstance(out, file):
+        if isinstance(out, BUILTIN_FILE_TYPE):
             self.std_out = out
         else:
             raise Exception("MessageBase: input parameter 'out' must be of type: file")


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-05-16  2:30 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-05-16  2:30 UTC (permalink / raw
  To: gentoo-commits

commit:     978f9d5a029311bff5b71604c2e46f400348530f
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 02:30:04 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=978f9d5a

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     | 10 +++++-----
 layman/makeconf.py   |  2 +-
 6 files changed, 20 insertions(+), 20 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..5a51495 100644
--- a/layman/dbbase.py
+++ b/layman/dbbase.py
@@ -115,7 +115,7 @@ class DbBase(object):
 
 
     def __eq__(self, other):
-        for key in set(list(self.overlays.keys()) + list(other.overlays.keys())):
+        for key in set(self.overlays.keys()) | set(self.other.overlays.keys()):
             if self.overlays[key] != other.overlays[key]:
                 return False
         return True
@@ -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


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-16  3:37 Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     e66be21d91f4f5264e1933a03271c4eca5f14d31
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 29 07:32:48 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e66be21d

{argsparser, cli}.py: adds --readd cli option

---
 layman/argsparser.py | 11 +++++++++--
 layman/cli.py        | 18 +++++++++++++++++-
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index aa1cde3..f868cca 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -40,9 +40,9 @@ from layman.version import VERSION
 
 
 _USAGE = """
-  layman (-a|-d|-s|-i) (OVERLAY|ALL)
+  layman (-a|-d|-r|-s|-i) (OVERLAY|ALL)
   # it also supports multiple actions
-  layman (-a|-d|-s|-i) (OVERLAY|ALL) [ [(-a|-d|-s|-i) (OVERLAY)] ...]
+  layman (-a|-d|-r|-s|-i) (OVERLAY|ALL) [ [(-a|-d|-r|-s|-i) (OVERLAY)] ...]
   layman -f [-o URL]
   layman (-l|-L|-S)"""
 
@@ -144,6 +144,13 @@ class ArgsParser(BareConfig):
                              'ing order of the overlays in the PORTDIR_OVERLAY varia'
                              'ble.')
 
+        actions.add_argument('-r',
+                             '--readd',
+                             action = 'append',
+                             help = 'Remove and re-add the given overlay from the cached'
+                             ' remote list to your locally installed overlays... Specify'
+                             ' "ALL" to re-add all local overlays.')
+
         actions.add_argument('-s',
                              '--sync',
                              action = 'append',

diff --git a/layman/cli.py b/layman/cli.py
index 159b413..f0dc181 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -134,7 +134,6 @@ class Main(object):
 
     def __init__(self, config):
         self.config = config
-        #print "config.keys()", config.keys()
         self.output = config['output']
         self.api = LaymanAPI(config,
                              report_errors=False,
@@ -145,6 +144,7 @@ class Main(object):
                         ('sync',       'Sync'),
                         ('info',       'Info'),
                         ('sync_all',   'Sync'),
+                        ('readd',      'Readd'),
                         ('delete',     'Delete'),
                         ('list',       'ListRemote'),
                         ('list_local', 'ListLocal'),]
@@ -251,6 +251,22 @@ class Main(object):
         return result
 
 
+    def Readd(self):
+        '''Readds the selected overlay(s).
+        '''
+        self.output.info('Reinstalling overlay(s),...', 2)
+        selection = decode_selection(self.config['readd'])
+        if ALL_KEYWORD in selection:
+            selection = self.api.get_installed()
+        self.output.debug('Reinstalling selected overlay(s)', 6)
+        result = self.api.readd_repos(selection, update_news=True)
+        if result:
+            self.output.info('Successfully reinstalled overlay(s) ' +
+                ', '.join((x.decode('UTF-8') if isinstance(x, bytes) else x) for x in selection)
+                + '.', 2)
+        self.output.notice('')
+        return result
+
 
     def Sync(self):
         ''' Syncs the selected overlays.


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-16  3:37 Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     ccad04bd179ea25be90283bbcee74628ecce47a5
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 21:59:10 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ccad04bd

db.py: adds update() function

---
 layman/db.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/layman/db.py b/layman/db.py
index c4e322e..fa28e06 100644
--- a/layman/db.py
+++ b/layman/db.py
@@ -222,6 +222,23 @@ class DB(DbBase):
             return False
         return True
 
+
+    def update(self, overlay, available_srcs):
+        '''
+        Updates the overlay source via the available source(s).
+        
+        @params overlay: layman.overlay.Overlay object.
+        @params available_srcs: set of available source URLs.
+        '''
+
+        source, result = self.overlays[overlay.name].update(self.config['storage'],
+                                                    available_srcs)
+        self.overlays[overlay.name].sources = source
+        self.repo_conf.update(self.overlays[overlay.name])
+        self.write(self.path)
+
+        return result
+
     def sync(self, overlay_name):
         '''Synchronize the given overlay.'''
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
  2014-06-16  3:40 [gentoo-commits] proj/layman:master commit in: layman/ Brian Dolbec
@ 2014-06-16  3:37 ` Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     4c5e1f9c86d074d2b220adf3fcf892a06c23256f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 29 06:58:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4c5e1f9c

api.py: fixes success assignment in delete_repos()

---
 layman/api.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/api.py b/layman/api.py
index 413f8d0..041b737 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -118,7 +118,7 @@ class LaymanAPI(object):
                 continue
             success = False
             try:
-                self._get_installed_db().delete(
+                success = self._get_installed_db().delete(
                     self._get_installed_db().select(ovl))
             except Exception as e:
                 self._error(


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-16  3:37 Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f1e023c68411ac7319e163c66a41fcaf55193e1f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 29 07:09:28 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f1e023c6

api.py: fixes byte string output for update_news()

---
 layman/api.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/layman/api.py b/layman/api.py
index 041b737..d9d3eb1 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -639,6 +639,8 @@ class LaymanAPI(object):
                     # because it may be different than layman's name for it
                     repo_names = []
                     for repo in repos:
+                        if isinstance(repo, bytes):
+                            repo = repo.decode('UTF-8')
                         ovl = self._get_installed_db().select(repo)
                         ovl_path = os.path.join(ovl.config['storage'], repo)
                         name = portdb.getRepositoryName(ovl_path)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
  2014-06-16  3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
@ 2014-06-16  3:37 ` Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f7896d0585a82f73cb20fb0d5a6e7ea7e50c77b3
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 22:07:07 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f7896d05

api.py: incorporates db.update() in api.sync()

---
 layman/api.py | 83 +++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 52 insertions(+), 31 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index b5b6a2a..413f8d0 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -342,6 +342,49 @@ class LaymanAPI(object):
             return True, msg
         return False, ''
 
+    def _verify_overlay_source(self, odb, ordb)
+        """
+        Verifies the overlay source url against the source url(s)
+        reported by the remote database.
+
+        @param odb: local database of overlay information.
+        @param ordb: remote database of overlay information.
+        @rtype (boolean, msg)
+        """
+        current_src = odb.sources[0].src
+        (available_srcs, valid) = verify_overlay_src(current_src,
+            set(e.src for e in ordb.sources))
+            
+        if ordb and odb and not valid:
+            update_url = True
+            if len(available_srcs) == 1:
+                plural = ''
+                candidates = '  %s' % tuple(available_srcs)[0]
+            else:
+                plural = 's'
+                candidates = '\n'.join(('  %d. %s' % (ovl + 1, v)) \
+                    for ovl, v in enumerate(available_srcs))
+            msg = 'The source of the overlay "%(repo_name)s" seems to have changed.\n'\
+                  'You currently sync from\n'\
+                  '\n'\
+                  '  %(current_src)s\n'
+                  '\n'\
+                  'while the remote lists report\n'\
+                  '\n'\
+                  '%(candidates)s\n'\
+                  '\n'\
+                  'as correct location%(plural)s.\n'\
+                  '\n'\
+                  'Repo: "%(repo_name)s" will be updated...' %\
+                  ({
+                     'repo_name':odb.name,
+                     'current_src':current_src,
+                     'candidates':candidates,
+                     'plural':plural,
+                  })
+            return True, msg
+        return False, ''
+
     def sync(self, repos, output_results=True, update_news=False):
         """syncs the specified repo(s) specified by repos
 
@@ -360,6 +403,7 @@ class LaymanAPI(object):
 
         self.output.debug("API.sync(); starting ovl loop", 5)
         for ovl in repos:
+            update_url = False
             self.output.debug("API.sync(); starting ovl = %s" %ovl, 5)
             try:
                 #self.output.debug("API.sync(); selecting %s, db = %s" % (ovl, str(db)), 5)
@@ -384,39 +428,9 @@ class LaymanAPI(object):
                 warnings.append((ovl, message))
             else:
                 self.output.debug("API.sync(); else: self._get_remote_db().select(ovl)", 5)
-                current_src = odb.sources[0].src
-                (available_srcs, valid) = verify_overlay_src(current_src, 
-                                            set(e.src for e in ordb.sources))
 
                 (diff_type, type_msg) = self._verify_overlay_type(odb, ordb)
-
-                if ordb and odb and not valid:
-                    if len(available_srcs) == 1:
-                        plural = ''
-                        candidates = '  %s' % tuple(available_srcs)[0]
-                    else:
-                        plural = 's'
-                        candidates = '\n'.join(('  %d. %s' % (ovl + 1, v)) \
-                         for ovl, v in enumerate(available_srcs))
-
-                    warnings.append((ovl,
-                        'The source of the overlay "%(repo_name)s" seems to have changed.\n'
-                        'You currently sync from\n'
-                        '\n'
-                        '  %(current_src)s\n'
-                        '\n'
-                        'while the remote lists report\n'
-                        '\n'
-                        '%(candidates)s\n'
-                        '\n'
-                        'as correct location%(plural)s.\n'
-                        'Please consider removing and re-adding the overlay.' %
-                        {
-                            'repo_name':ovl,
-                            'current_src':current_src,
-                            'candidates':candidates,
-                            'plural':plural,
-                            }))
+                (update_url, url_msg) = self._verify_overlay_source(odb, ordb)
 
             try:
                 if diff_type:
@@ -425,6 +439,13 @@ class LaymanAPI(object):
                     self.readd_repos(ovl)
                     success.append((ovl, 'Successfully readded overlay "' + ovl + '".'))
                 else:
+                    if update_url:
+                        self.output.debug("API.sync() starting db.update(ovl)", 5)
+                        warnings.append((ovl, url_msg))
+                        update_success = db.update(ordb, available_srcs)
+                        if not update_success:
+                            self.output.warn('Failed to update repo...readding', 2)
+                            self.readd_repos(ovl)
                     self.output.debug("API.sync(); starting db.sync(ovl)", 5)
                     db.sync(ovl)
                     success.append((ovl,'Successfully synchronized overlay "' + ovl + '".'))


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
  2014-06-16  3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
@ 2014-06-16  3:37 ` Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f8132d4a8c8bf44ed90bef88c35eb9565e6a4a4d
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  1 22:23:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=f8132d4a

config.py: moves EPREFIX constant to top of file

---
 layman/config.py | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 9d2bc7f..31dc0ac 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -27,7 +27,6 @@ from __future__ import unicode_literals
 __version__ = "0.2"
 
 
-
 import sys
 import os
 
@@ -41,6 +40,13 @@ except:
 from layman.output import Message
 from layman.utils import path
 
+# establish the eprefix, initially set so eprefixify can
+# set it on install
+EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
+# check and set it if it wasn't
+if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
+    EPREFIX = ''
+
 def read_layman_config(config=None, defaults=None, output=None):
     """reads the config file defined in defaults['config']
     and updates the config
@@ -66,14 +72,6 @@ def read_layman_config(config=None, defaults=None, output=None):
                 overlays.update(["file://" + _path])
         config.set('MAIN', 'overlays', '\n'.join(overlays))
 
-# establish the eprefix, initially set so eprefixify can
-# set it on install
-EPREFIX = "@GENTOO_PORTAGE_EPREFIX@"
-
-# check and set it if it wasn't
-if "GENTOO_PORTAGE_EPREFIX" in EPREFIX:
-    EPREFIX = ''
-
 
 class BareConfig(object):
     '''Handles the configuration only.'''


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-16  3:37 Brian Dolbec
  0 siblings, 0 replies; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:37 UTC (permalink / raw
  To: gentoo-commits

commit:     095db013be3d0ab6c5ad4dec14d56cd0facaa192
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  5 14:52:06 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jun 14 22:06:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=095db013

reposconf.py: Adds overlay priority value

---
 layman/reposconf.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/layman/reposconf.py b/layman/reposconf.py
index 3216591..a7a0166 100644
--- a/layman/reposconf.py
+++ b/layman/reposconf.py
@@ -78,6 +78,7 @@ class ConfigHandler:
         @return boolean: reflects a successful/failed write to the config file.
         '''
         self.repo_conf.add_section(overlay.name)
+        self.repo_conf.set(overlay.name, 'priority', str(overlay.priority))
         self.repo_conf.set(overlay.name, 'location', path((self.storage, overlay.name)))
         self.repo_conf.set(overlay.name, 'sync-uri', overlay.sources[0].src)
         self.repo_conf.set(overlay.name, 'auto-sync', self.config['auto_sync'])


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:master commit in: layman/
@ 2014-06-16  3:40 Brian Dolbec
  2014-06-16  3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
  0 siblings, 1 reply; 62+ messages in thread
From: Brian Dolbec @ 2014-06-16  3:40 UTC (permalink / raw
  To: gentoo-commits

commit:     4c5e1f9c86d074d2b220adf3fcf892a06c23256f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 29 06:58:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jun 12 21:11:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=4c5e1f9c

api.py: fixes success assignment in delete_repos()

---
 layman/api.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/api.py b/layman/api.py
index 413f8d0..041b737 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -118,7 +118,7 @@ class LaymanAPI(object):
                 continue
             success = False
             try:
-                self._get_installed_db().delete(
+                success = self._get_installed_db().delete(
                     self._get_installed_db().select(ovl))
             except Exception as e:
                 self._error(


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-27  4:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-06-27  4:07 UTC (permalink / raw
  To: gentoo-commits

commit:     fc428382a7b37ea19d91fef046482e6d574df9dd
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 01:07:21 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Jun 17 01:07:21 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fc428382

config.py: Improves quietness logic for OptionConfig

This improvement prevents KeyError exceptions.

---
 layman/config.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index 761dd57..ead56cf 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -302,7 +302,7 @@ class BareConfig(object):
 
 
 class OptionConfig(BareConfig):
-    """This subclasses BareCongig adding functions to make overriding
+    """This subclasses BareConfig adding functions to make overriding
     or resetting defaults and/or setting options much easier
     by using dictionaries.
     """
@@ -340,7 +340,7 @@ class OptionConfig(BareConfig):
             if 'quiet' in keys:
                 self.set_option('quiet', options['quiet'])
                 options.pop('quiet')
-            if 'quietness' in keys and not options['quiet']:
+            elif 'quietness' in keys:
                 self._set_quietness(options['quietness'])
                 options.pop('quietness')
             self._options.update(options)


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-27  4:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-06-27  4:07 UTC (permalink / raw
  To: gentoo-commits

commit:     037f63818987de89e601bbed75b1248bb43f6c89
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 21:32:41 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:57 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=037f6381

argsparser.py: Adds --storage cli option

---
 layman/argsparser.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index f868cca..ff5d67f 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -196,6 +196,13 @@ class ArgsParser(BareConfig):
                                help = 'Path to aditional overlay.xml files [default: '
                                '%s].' % (self.defaults['overlay_defs'] %self.defaults))
 
+        path_opts.add_argument('-z',
+                               '--storage',
+                               action = 'store',
+                               default = '/var/lib/layman',
+                               help = 'Directory path to user for layman overlay inst'
+                               'allation location [default: /var/lib/layman].')
+
         #-----------------------------------------------------------------
         # Output Options
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-06-27  4:07 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-06-27  4:07 UTC (permalink / raw
  To: gentoo-commits

commit:     a1f6aa1a73fbaef1d7398003897dab46f58f66d4
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 17 21:46:57 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Jun 19 03:49:58 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a1f6aa1a

reposconf.py: Adds sync-type checking

---
 layman/reposconf.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/layman/reposconf.py b/layman/reposconf.py
index c550a13..b93ee42 100644
--- a/layman/reposconf.py
+++ b/layman/reposconf.py
@@ -24,6 +24,12 @@ except:
     # Import for Python2
     import ConfigParser
 
+try:
+    from portage.sync.modules import layman_
+    sync_type = "layman"
+except ImportError:
+    sync_type = "None"
+
 from   layman.compatibility  import fileopen
 from   layman.utils          import path
 
@@ -81,6 +87,7 @@ class ConfigHandler:
         self.repo_conf.add_section(overlay.name)
         self.repo_conf.set(overlay.name, 'priority', str(overlay.priority))
         self.repo_conf.set(overlay.name, 'location', path((self.storage, overlay.name)))
+        self.repo_conf.set(overlay.name, 'sync-type', sync_type)
         self.repo_conf.set(overlay.name, 'sync-uri', overlay.sources[0].src)
         self.repo_conf.set(overlay.name, 'auto-sync', self.config['auto_sync'])
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-08-15 22:32 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-08-15 22:32 UTC (permalink / raw
  To: gentoo-commits

commit:     89bf796adb52fac6c9472f5dc40bc137e4ab0d44
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 10 20:26:45 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 15 20:57:38 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=89bf796a

api.py: Adds disable and enable repo functions

X-Gentoo-Bug: 512316
X-Gentoo-Bug-URL: https://bugs.gentoo.org/512316

---
 layman/api.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 17c7998..bae6972 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -122,7 +122,7 @@ class LaymanAPI(object):
                     self._get_installed_db().select(ovl))
             except Exception as e:
                 self._error(
-                        "Exception caught disabling repository '"+ovl+
+                        "Exception caught removing repository '"+ovl+
                             "':\n"+str(e))
             results.append(success)
             self.get_installed(dbreload=True)
@@ -155,7 +155,7 @@ class LaymanAPI(object):
                 success = self._get_installed_db().add(
                     self._get_remote_db().select(ovl))
             except Exception as e:
-                self._error("Exception caught enabling repository '"+ovl+
+                self._error("Exception caught installing repository '"+ovl+
                     "' : "+str(e))
             results.append(success)
             self.get_installed(dbreload=True)
@@ -183,6 +183,56 @@ class LaymanAPI(object):
         return success
 
 
+    def disable_repos(self, repos, update_news=False):
+        repos = self._check_repo_type(repos, "disable_repo")
+        results = []
+        for ovl in repos:
+            if not self.is_repo(ovl):
+                self.output.error(UnknownOverlayMessage(ovl))
+                result.append(False)
+                continue
+            success = False
+            try:
+                success = self._get_installed_db().disable(
+                    self._get_installed_db().select(ovl))
+            except Exception as e:
+                self._error('Exception caught disabling repository "%(repo)s"'\
+                    ': %(err)s' % ({'repo': ovl, 'err': e}))
+            results.append(success)
+            self.get_installed(dbreload=True)
+        if (True in results) and update_news:
+            self.update_news(repos)
+
+        if False in results:
+            return False
+        return True
+
+
+    def enable_repos(self, repos, update_news=False):
+        repos = self._check_repo_type(repos, "enable_repo")
+        results = []
+        for ovl in repos:
+            if not self.is_repo(ovl):
+                self.output.error(UnknownOverlayMessage(ovl))
+                result.append(False)
+                continue
+            success = False
+            try:
+                success = self._get_installed_db().enable(
+                    self._get_installed_db().select(ovl))
+            except Exception as e:
+                self._error('Exception caught enabling repository "%(repo)s"'\
+                    ': %(err)s' % ({'repo': ovl, 'err': e}))
+            results.append(success)
+            self.get_installed(dbreload=True)
+        if (True in results) and update_news:
+            self.update_news(repos)
+
+        if False in results:
+            return False
+        return True
+
+
     def get_all_info(self, repos, local=False):
         """retrieves the recorded information about the repo(s)
         specified by repo-id


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-08-15 22:32 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-08-15 22:32 UTC (permalink / raw
  To: gentoo-commits

commit:     ba74abf654a9592841cdf114fcd61dddc15350e0
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 10 20:30:20 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 15 20:57:38 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ba74abf6

cli.py: Adds disable and enable cli functions

argsparser.py: Adds --disable and --enable cli args.

X-Gentoo-Bug: 512316
X-Gentoo-Bug-URL: https://bugs.gentoo.org/512316

---
 layman/argsparser.py | 12 ++++++++++++
 layman/cli.py        | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/layman/argsparser.py b/layman/argsparser.py
index 56813f0..aa8c291 100644
--- a/layman/argsparser.py
+++ b/layman/argsparser.py
@@ -95,6 +95,18 @@ class ArgsParser(BareConfig):
                              help = 'Remove the given overlay from your locally inst'
                              'alled overlays. Specify "ALL" to remove all overlays.')
 
+        actions.add_argument('-D',
+                             '--disable',
+                             nargs = '+',
+                             help = 'Disable the given overlay from portage. Specify'
+                             ' "ALL" to disable all installed overlay.')
+
+        actions.add_argument('-E',
+                             '--enable',
+                             nargs = '+',
+                             help = 'Re-enable a previously disabled overlay. Specif'
+                             'y "ALL" to enable all installed overlays.')
+
         actions.add_argument('-f',
                              '--fetch',
                              action = 'store_true',

diff --git a/layman/cli.py b/layman/cli.py
index 28b19fb..bb84081 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -146,6 +146,8 @@ class Main(object):
                         ('sync_all',   'Sync'),
                         ('readd',      'Readd'),
                         ('delete',     'Delete'),
+                        ('disable',    'Disable'),
+                        ('enable',     'Enable'),
                         ('list',       'ListRemote'),
                         ('list_local', 'ListLocal'),]
 
@@ -300,6 +302,44 @@ class Main(object):
         return result
 
 
+    def Disable(self):
+        '''
+        Disable the selected overlay(s).
+
+        @rtype bool
+        '''
+        self.output.info('Disabling selected overlay(s),...', 2)
+        selection = decode_selection(self.config['disable'])
+        if ALL_KEYWORD in selection:
+            selection = self.api.get_installed()
+        result = self.api.disable_repos(selection)
+        if result:
+            self.output.info('Successfully disabled overlay(s) ' +
+                ', '.join((x.decode('UTF-8') if isinstance(x, bytes) else x) for x in selection) +
+                '.', 2)
+        self.output.notice('')
+        return result
+
+
+    def Enable(self):
+        '''
+        Enable the selected overlay(s).
+
+        @rtype bool
+        '''
+        self.output.info('Enabling the selected overlay(s),...', 2)
+        selection = decode_selection(self.config['enable'])
+        if ALL_KEYWORD in selection:
+            selection = self.api.get_installed()
+        result = self.api.enable_repos(selection)
+        if result:
+            self.output.info('Successfully enable overlay(s) ' +
+                ', '.join((x.decode('UTF-8') if isinstance(x, bytes) else x) for x in selection) +
+                '.', 2)
+        self.output.notice('')
+        return result
+
+
     def Info(self):
         ''' Print information about the specified overlay(s).
         '''


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-08-15 22:32 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-08-15 22:32 UTC (permalink / raw
  To: gentoo-commits

commit:     c7b86d60b7c32f5bc858a428547e175eab579967
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 29 00:05:59 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 15 21:42:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=c7b86d60

module.py: Adds modular plugin system

---
 layman/module.py | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 211 insertions(+)

diff --git a/layman/module.py b/layman/module.py
new file mode 100644
index 0000000..6d7a40b
--- /dev/null
+++ b/layman/module.py
@@ -0,0 +1,211 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from __future__ import print_function
+
+import os
+
+from layman.output import Message
+
+class InvalidModuleName(Exception):
+    '''An invalid or unknown module name.'''
+
+class Module(object):
+    '''
+    Class to define and hold our plugin-module
+
+    @type name: string
+    @param name: The module name
+    @type namepath: string
+    @param namepath: The path to the new module
+    @param output: The output for any information
+    '''
+    def __init__(self, name, namepath, output):
+        self.name = name
+        self._namepath = namepath
+        self.kids_names = []
+        self.kids = {}
+        self.output = output
+        self.initialized = self._initialize()
+
+
+    def _initialize(self):
+        '''
+        Initializes the plug-in module
+
+        @rtype bool: reflects success or failure to initialize the module
+        '''
+        self.valid = False
+        try:
+            mod_name = '.'.join([self._namepath, self.name])
+            self._module = __import__(mod_name, [], [], ['not empty'])
+            self.valid = True
+        except ImportError as e:
+            self.output.error('Module._initialize(); failed to import %(mod) '\
+                'error was: %(err)' % ({'err': e, 'mod': mod_name}))
+            return False
+        self.module_spec = self._module.module_spec
+        for submodule in self.module_spec['provides']:
+            kid = self.module_spec['provides'][submodule]
+            kidname = kid['name']
+            kid['module_name'] = '.'.join([mod_name, self.name])
+            kid['is_imported'] = False
+            self.kids[kidname] = kid
+            self.kids_names.append(kidname)
+        return True
+
+
+    def get_class(self, name):
+        '''
+        Retrieves a module class desired
+
+        @type name: string
+        @param name: the plug-in module's name
+        @rtype mod_class: instance of plug-in module's class
+        '''
+        if not name or name not in self.kids_names:
+            raise InvalidModuleName('Module name "%(name)" was invalid or not'\
+                    'part of the module "%(mod_name)"' ({'mod_name':self.name,
+                                                         'name': name}))
+        kid = self.kids[name]
+        if kid['is_imported']:
+            module = kid['instance']
+        else:
+            try:
+                module = __import__(kid['module_name'], [], [], ["not empty"])
+                kid['instance'] = module
+                kid['is_imported'] = True
+            except ImportError:
+                raise
+        mod_class = getattr(module, kid['class'])
+        return mod_class
+
+
+class Modules(object):
+    '''
+    Dynamic module system for loading and retrieving any of the
+    installed layman modules and/or provided class'
+
+    @param path: Optional path to the "modules" directory or defaults to
+                 the directory of this file + "/modules"
+    @param namepath: Optional python import path to the "modules" directory or
+                     defaults to the directory name of this file + ".modules"
+    @param output: Optional output, defaults to layman.output.Message object
+    '''
+    def __init__(self, path=None, namepath=None, output=None):
+        if path:
+            self._module_path = path
+        else:
+            self._module_path = os.path.join(
+                (os.path.dirname(os.path.realpath(__file__))), 'modules')
+        if namepath:
+            self._namepath = namepath
+        else:
+            self._namepath = '.'.join(os.path.dirname(
+                os.path.realpath(__file__)), 'modules')
+        if output:
+            self.output = output
+        else:
+            self.output = Message()
+        self._modules = self._get_all_modules()
+        self.module_names = sorted(self._modules)
+
+
+    def _get_all_modules(self):
+        '''
+        Scans the overlay modules dir for loadable modules
+
+        @rtype dict of module_plugins
+        '''
+        module_dir = self._module_path
+        importables = []
+        names = os.listdir(module_dir)
+        for entry in names:
+            if entry.startswith('__'):
+                continue
+            try:
+                os.lstat(os.path.join(module_dir, entry, '__init__.py'))
+                importables.append(entry)
+            except EnvironmentError:
+                pass
+
+        kids = {}
+        for entry in importables:
+            new_module = Module(entry, self._namepath, self.output)
+            for module_name in new_module.kids:
+                kid = new_module.kids[module_name]
+                kid['parent'] = new_module
+                kids[kid['name']] = kid
+        return kids
+
+
+    def get_module_names(self):
+        '''
+        Retrieves all available module names
+
+        @rtype: list of installed module names available
+        '''
+        return self.module_names
+
+
+    def get_class(self, modname):
+        '''
+        Retrieves a module class desired
+
+        @type modname: string
+        @param modname: the module class name
+        '''
+        if modname and modname in self.module_names:
+            mod = self._modules[modname]['parent'].get_class(modname)
+        else:
+            raise InvalidModuleName('Module name "%(name)s" was invalid or'\
+                ' not found.' % ({'name': modname}))
+        return mod
+
+
+    def get_description(self, modname):
+        '''
+        Retrieves the module class decription
+
+        @type modname: string
+        @param modname: the module class name
+        @rtype: string of modules class decription
+        '''
+        if modname and modname in self.module_names:
+            mod = self._modules[modname]['description']
+        else:
+            raise InvalidModuleName('Module name "%(name)s" was invalid or'\
+                ' not found.' % ({'name': modname}))
+        return mod
+
+
+    def get_functions(self, modname):
+        '''
+        Retrieves the module class exported function names
+
+        @type modname: string
+        @param modname: the module class name
+        @rtype: list of the modules class exported function names
+        '''
+        if modname and modname in self.module_names:
+            mod = self._modules[modname]['functions']
+        else:
+            raise InvalidModuleName('Module name "%(name)s" was invalid or'\
+                ' not found.' % ({'name': modname}))
+        return mod
+
+
+    def get_func_descriptions(self, modname):
+        '''
+        Retrieves the module class  exported functions descriptions
+
+        @type modname: string
+        @param modname: the module class name
+        @rtype: dict of the modules class exported functions descriptions
+        '''
+        if modname and modname in self.module_names:
+            desc = self._modules[modname]['func_desc']
+        else:
+            raise InvalidModuleName('Module name "%(name)s" was invalid or'\
+                ' not found.' % ({'name': modname}))
+        return desc


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
@ 2014-08-15 22:32 Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-08-15 22:32 UTC (permalink / raw
  To: gentoo-commits

commit:     74a5d6e23ea52f4bb2d19d1deb0b9abc36b20f23
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Aug  1 04:36:07 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 15 21:42:42 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=74a5d6e2

api.py: Makes supported_types() check for modules

Prior to executing require_supported() and notifying a user that the
overlay type isn't supported due to not finding the proper command
bin, a check has been made to see if the overlay module has been
brought in by the user. This will prevent unnecessary complaining from
layman.

---
 layman/api.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index 0f43f28..b3f33f6 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -624,12 +624,25 @@ class LaymanAPI(object):
     def supported_types(self):
         """returns a dictionary of all repository types,
         with boolean values"""
+        here = os.path.dirname(os.path.realpath(__file__))
+        modpath = os.path.join('overlays', 'modules')
+        modules = os.path.listdir(os.path.join(here, modpath))
+
         cmds = [x for x in self.config.keys() if '_command' in x]
         supported = {}
         for cmd in cmds:
             type_key = cmd.split('_')[0]
-            supported[type_key] = require_supported(
-                [(self.config[cmd],type_key, '')], self.output.warn)
+            # The module dir might be named differently from the type_key.
+            # ex.) g-common and g-sorcery are named g_common and g_sorcery.
+            module = type_key.replace('-', '_')
+
+            # Don't bother executing require_supported() if the user didn't
+            # bring in support for the overlay type in the first place.
+            if module in modules:
+                supported[type_key] = require_supported(
+                    [(self.config[cmd],type_key, '')], self.output.warn)
+            else:
+                supported[type_key] = False
         return supported
 
 


^ permalink raw reply related	[flat|nested] 62+ messages in thread

* [gentoo-commits] proj/layman:gsoc2014 commit in: layman/
  2014-08-15 23:59 [gentoo-commits] proj/layman:master " Devan Franchini
@ 2014-08-16  0:00 ` Devan Franchini
  0 siblings, 0 replies; 62+ messages in thread
From: Devan Franchini @ 2014-08-16  0:00 UTC (permalink / raw
  To: gentoo-commits

commit:     586a89a52c6ff564016780718fc07518dcea05fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 15 23:59:46 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 15 23:59:46 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=586a89a5

api.py: Modifies supported_types() module checking

---
 layman/api.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/layman/api.py b/layman/api.py
index b3f33f6..bb63d8d 100755
--- a/layman/api.py
+++ b/layman/api.py
@@ -626,7 +626,7 @@ class LaymanAPI(object):
         with boolean values"""
         here = os.path.dirname(os.path.realpath(__file__))
         modpath = os.path.join('overlays', 'modules')
-        modules = os.path.listdir(os.path.join(here, modpath))
+        modules = os.listdir(os.path.join(here, modpath))
 
         cmds = [x for x in self.config.keys() if '_command' in x]
         supported = {}


^ permalink raw reply related	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2014-08-16  0:00 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-16  3:40 [gentoo-commits] proj/layman:master commit in: layman/ Brian Dolbec
2014-06-16  3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2014-08-15 23:59 [gentoo-commits] proj/layman:master " Devan Franchini
2014-08-16  0:00 ` [gentoo-commits] proj/layman:gsoc2014 " Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-08-15 22:32 Devan Franchini
2014-06-27  4:07 Devan Franchini
2014-06-27  4:07 Devan Franchini
2014-06-27  4:07 Devan Franchini
2014-06-16  3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:40 [gentoo-commits] proj/layman:master " Brian Dolbec
2014-06-16  3:37 ` [gentoo-commits] proj/layman:gsoc2014 " Brian Dolbec
2014-06-16  3:37 Brian Dolbec
2014-06-16  3:37 Brian Dolbec
2014-06-16  3:37 Brian Dolbec
2014-06-16  3:37 Brian Dolbec
2014-05-16  2:30 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  1:07 Devan Franchini
2014-05-16  0:58 Devan Franchini
2014-05-16  0:58 Devan Franchini
2014-05-16  0:57 Devan Franchini
2014-05-15 20:46 Devan Franchini
2014-05-15 20:46 Devan Franchini
2014-05-15 20:37 Devan Franchini
2014-05-15 20:30 Devan Franchini
2014-05-15 20:02 Devan Franchini
2014-05-15  0:04 Devan Franchini
2014-05-14 23:54 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 23:49 Devan Franchini
2014-05-14 22:16 Devan Franchini
2014-05-14 22:08 Devan Franchini
2014-05-14 21:42 Devan Franchini
2014-05-14 21:30 Devan Franchini
2014-05-14 21:15 Devan Franchini
2014-05-14 21:15 Devan Franchini
2014-05-14 19:29 Devan Franchini
2014-05-14 18:55 Devan Franchini
2014-05-14 18:44 Devan Franchini
2014-05-14 17:32 Devan Franchini
2014-05-14  3:21 Devan Franchini
2014-05-14  0:37 Devan Franchini
2014-05-07 22:21 Devan Franchini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox