public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-02-14  6:00 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-02-14  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     3731e182e0577165ede11e95d4bd447354ce3786
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Wed Jul  7 01:08:46 2010 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Feb 11 10:48:36 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=3731e182

Change the remaining modules to use the config['output'] variable so re-direction is possible for all output.

---
 layman/overlays/overlay.py |   10 ++++++----
 layman/overlays/source.py  |   13 +++++++------
 layman/overlays/tar.py     |    6 ++++--
 3 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 2333d72..4036458 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -35,7 +35,7 @@ import xml.etree.ElementTree as ET # Python 2.5
 
 from   layman.utils             import ensure_unicode
 
-from   layman.debug             import OUT
+#from   layman.debug             import OUT
 
 from   layman.overlays.bzr       import BzrOverlay
 from   layman.overlays.darcs     import DarcsOverlay
@@ -100,6 +100,8 @@ class Overlay(object):
         False
         '''
 
+        self.output = config['output']
+        
         def strip_text(node):
             res = node.text
             if res is None:
@@ -161,7 +163,7 @@ class Overlay(object):
                 raise Exception('Overlay "' + self.name + '" is missing a '
                                 '"owner.email" entry!')
             elif ignore == 1:
-                OUT.warn('Overlay "' + self.name + '" is missing a '
+                self.output.warn('Overlay "' + self.name + '" is missing a '
                          '"owner.email" entry!', 4)
 
 
@@ -176,7 +178,7 @@ class Overlay(object):
                 raise Exception('Overlay "' + self.name + '" is missing a '
                         '"description" entry!')
             elif ignore == 1:
-                OUT.warn('Overlay "' + self.name + '" is missing a '
+                self.output.warn('Overlay "' + self.name + '" is missing a '
                          '"description" entry!', 4)
 
         if 'status' in xml.attrib:
@@ -279,7 +281,7 @@ class Overlay(object):
                     self.sources = [s]
                     break
             except Exception, error:
-                OUT.warn(str(error), 4)
+                self.output.warn(str(error), 4)
         return res
 
     def sync(self, base, quiet = False):

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 2c039c9..9f7eaef 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -18,7 +18,7 @@ import copy
 import sys
 import shutil
 import subprocess
-from layman.debug import OUT
+#from layman.debug import OUT
 from layman.utils import path
 
 
@@ -58,6 +58,7 @@ class OverlaySource(object):
         self.config = config
         self.ignore = ignore
         self.quiet = quiet
+        self.output = config['output']
 
     def __eq__(self, other):
         return self.src == other.src
@@ -85,10 +86,10 @@ class OverlaySource(object):
         mdir = path([base, self.parent.name])
 
         if not os.path.exists(mdir):
-            OUT.warn('Directory ' + mdir + ' did not exist, no files deleted.')
+            self.output.warn('Directory ' + mdir + ' did not exist, no files deleted.')
             return
 
-        OUT.info('Deleting directory "%s"' % mdir, 2)
+        self.output.info('Deleting directory "%s"' % mdir, 2)
         shutil.rmtree(mdir)
 
     def supported(self):
@@ -127,7 +128,7 @@ class OverlaySource(object):
         if cwd:
             command_repr = '( cd %s  && %s )' % (cwd, command_repr)
 
-        OUT.info('Running... # %s' % command_repr, 2)
+        self.output.info('Running... # %s' % command_repr, 2)
 
         if self.quiet:
             input_source = subprocess.PIPE
@@ -140,7 +141,7 @@ class OverlaySource(object):
         proc = subprocess.Popen(args,
             stdin=input_source,
             stdout=output_target,
-            stderr=output_target,
+            stderr=self.config['stderr'],
             cwd=cwd,
             env=env)
 
@@ -151,7 +152,7 @@ class OverlaySource(object):
         try:
             result = proc.wait()
         except KeyboardInterrupt:
-            OUT.info('Interrupted manually', 2)
+            self.output.info('Interrupted manually', 2)
             result = 1
 
         if self.quiet:

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 919f4df..4916b77 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -28,7 +28,7 @@ import os, os.path, sys, urllib2, shutil, tempfile
 import xml.etree.ElementTree as ET # Python 2.5
 
 from   layman.utils             import path, ensure_unicode
-from   layman.debug             import OUT
+#from   layman.debug             import OUT
 from   layman.overlays.source   import OverlaySource, require_supported
 
 #===============================================================================
@@ -85,6 +85,8 @@ class TarOverlay(OverlaySource):
         else:
             self.subpath = ''
 
+        self.output = config['output']
+
     def __eq__(self, other):
         res = super(TarOverlay, self).__eq__(other) \
             and self.subpath == other.subpath
@@ -139,7 +141,7 @@ class TarOverlay(OverlaySource):
                 return
 
             try:
-                OUT.info('Deleting directory "%s"' % folder, 2)
+                self.output.info('Deleting directory "%s"' % folder, 2)
                 shutil.rmtree(folder)
             except Exception, error:
                 raise Exception('Failed to remove unnecessary tar structure "'



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-02-14  6:00 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-02-14  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     badca544dbd7e151e27b4f004962b139aa450ac3
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Feb 13 03:24:37 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 03:55:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=badca544

output more info to the trial for adding an overlay

---
 layman/overlays/overlay.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index f93530e..3f8c3b8 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -286,7 +286,10 @@ class Overlay(object):
 
     def add(self, base, quiet = False):
         res = 1
+        first_s = True
         for s in self.sources:
+            if not first_s:
+                self.output.info("\nTrying next source of listed sources...", 4)
             try:
                 res = s.add(base, quiet)
                 if res == 0:
@@ -295,6 +298,7 @@ class Overlay(object):
                     break
             except Exception, error:
                 self.output.warn(str(error), 4)
+            first_s = False
         return res
 
     def sync(self, base, quiet = False):



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-02-17 21:53 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-02-17 21:53 UTC (permalink / raw
  To: gentoo-commits

commit:     6d023e32aa94c42f6307f2263ac49a6f09d7680e
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Feb 17 21:49:28 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Feb 17 21:49:28 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6d023e32

shorten long lines

---
 layman/overlays/source.py |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 9f7eaef..e5cd880 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -1,7 +1,7 @@
 # -*- coding: utf-8 -*-
-#################################################################################
+###############################################################################
 # LAYMAN OVERLAY SOURCE BASE CLASS
-#################################################################################
+###############################################################################
 # File:       source.py
 #
 #             Base class for the different overlay types.
@@ -34,7 +34,8 @@ def _resolve_command(command):
             f = os.path.join(d, command)
             if os.path.exists(f):
                 return ('Command', f)
-        raise Exception('Cound not resolve command "%s" based on PATH "%s"' % (command, env_path))
+        raise Exception('Cound not resolve command ' +\
+            '"%s" based on PATH "%s"' % (command, env_path))
 
 
 def require_supported(binaries):
@@ -52,7 +53,8 @@ class OverlaySource(object):
 
     type_key = None
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, xml, config, _location,
+            ignore = 0, quiet = False):
         self.parent = parent
         self.src = _location
         self.config = config
@@ -72,8 +74,8 @@ class OverlaySource(object):
         mdir = path([base, self.parent.name])
 
         if os.path.exists(mdir):
-            raise Exception('Directory ' + mdir + ' already exists. Will not ov'
-                            'erwrite its contents!')
+            raise Exception('Directory ' + mdir +
+                ' already exists. Will not overwrite its contents!')
 
         os.makedirs(mdir)
 
@@ -86,7 +88,8 @@ class OverlaySource(object):
         mdir = path([base, self.parent.name])
 
         if not os.path.exists(mdir):
-            self.output.warn('Directory ' + mdir + ' did not exist, no files deleted.')
+            self.output.warn('Directory ' + mdir + \
+                ' did not exist, no files deleted.')
             return
 
         self.output.info('Deleting directory "%s"' % mdir, 2)
@@ -124,7 +127,8 @@ class OverlaySource(object):
 
         command_repr = ' '.join(args)
         if env_updates:
-            command_repr = '%s %s' % (' '.join('%s=%s' % (k, v) for (k, v) in sorted(env_updates.items())), command_repr)
+            command_repr = '%s %s' % (' '.join('%s=%s' % (k, v) for (k, v)
+                in sorted(env_updates.items())), command_repr)
         if cwd:
             command_repr = '( cd %s  && %s )' % (cwd, command_repr)
 



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-27 10:58 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     ba5f0cd5c948bb7a65ab21008c940caf0fbe38e7
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Feb 24 05:58:49 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Feb 24 06:49:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ba5f0cd5

removal of xml from the vcs class parameters.

---
 layman/overlays/bzr.py       |    5 +-
 layman/overlays/cvs.py       |   11 +--
 layman/overlays/darcs.py     |    4 +-
 layman/overlays/g_common.py  |    4 +-
 layman/overlays/git.py       |    6 +-
 layman/overlays/mercurial.py |    6 +-
 layman/overlays/overlay.py   |  177 +++++++++++++++++++++++++++++++++++-------
 layman/overlays/rsync.py     |    4 +-
 layman/overlays/source.py    |    3 +-
 layman/overlays/svn.py       |    4 +-
 layman/overlays/tar.py       |   12 +---
 11 files changed, 171 insertions(+), 65 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 6f1b560..1c2c702 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -41,9 +41,10 @@ class BzrOverlay(OverlaySource):
     type = 'Bzr'
     type_key = 'bzr'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(BzrOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+        super(BzrOverlay, self).__init__(parent,
+            config, _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 7d3f28f..2e76aa5 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -41,17 +41,10 @@ class CvsOverlay(OverlaySource):
     type = 'cvs'
     type_key = 'cvs'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(CvsOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+        super(CvsOverlay, self).__init__(parent, config, _location, ignore, quiet)
 
-        _subpath = xml.find('subpath')
-        if _subpath != None:
-            self.subpath = ensure_unicode(_subpath.text.strip())
-        elif 'subpath' in xml.attrib:
-            self.subpath = ensure_unicode(xml.attrib['subpath'])
-        else:
-            self.subpath = ''
 
     def __eq__(self, other):
         res = super(CvsOverlay, self).__eq__(other) \

diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index d393be7..566d6ba 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -40,9 +40,9 @@ class DarcsOverlay(OverlaySource):
     type = 'Darcs'
     type_key = 'darcs'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(DarcsOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+        super(DarcsOverlay, self).__init__(parent, config, _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index 5367c69..5be191d 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -38,8 +38,8 @@ class GCommonOverlay(OverlaySource):
     type = 'g-common'
     type_key = 'g-common'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
-        super(GCommonOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+        super(GCommonOverlay, self).__init__(parent, config, _location, ignore, quiet)
         #split source into driver and remote uri.
         self.driver=self.src[:self.src.find(' ')]
         self.remote_uri=self.src[self.src.find(' ')+1:]

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 23103f6..0c0404f 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -39,9 +39,9 @@ class GitOverlay(OverlaySource):
     type = 'Git'
     type_key = 'git'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
-
-        super(GitOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
+        super(GitOverlay, self).__init__(parent, config,
+            _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index df4f789..1d0cb92 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -40,9 +40,11 @@ class MercurialOverlay(OverlaySource):
     type = 'Mercurial'
     type_key = 'mercurial'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, config,
+        _location, ignore = 0, quiet = False):
 
-        super(MercurialOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+        super(MercurialOverlay, self).__init__(parent,
+            config, _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 3f8c3b8..aada4a2 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -1,8 +1,8 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
-#################################################################################
+################################################################################
 # LAYMAN OVERLAY BASE CLASS
-#################################################################################
+################################################################################
 # File:       overlay.py
 #
 #             Base class for the different overlay types.
@@ -20,7 +20,7 @@
 #
 ''' Basic overlay class.'''
 
-__version__ = "$Id: overlay.py 273 2006-12-30 15:54:50Z wrobel $"
+__version__ = "0.2"
 
 #===============================================================================
 #
@@ -35,7 +35,6 @@ import xml.etree.ElementTree as ET # Python 2.5
 
 from layman.utils import (pad, terminal_width, get_encoding, encoder,
     ensure_unicode)
-#from   layman.debug             import OUT
 
 from   layman.overlays.bzr       import BzrOverlay
 from   layman.overlays.darcs     import DarcsOverlay
@@ -69,20 +68,17 @@ QUALITY_LEVELS = 'core|stable|testing|experimental|graveyard'.split('|')
 
 WHITESPACE_REGEX = re.compile('\s+')
 
-#===============================================================================
-#
-# Class Overlay
-#
-#-------------------------------------------------------------------------------
 
 class Overlay(object):
     ''' Derive the real implementations from this.'''
 
-    def __init__(self, xml, config, ignore = 0, quiet = False):
+    def __init__(self, config, xml=None, ovl_dict=None,
+        ignore = 0, quiet = False
+        ):
         '''
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> import xml.etree.ElementTree as ET # Python 2.5
-        >>> document = ET.parse(here + '/../tests/testfiles/global-overlays.xml')
+        >>> document =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
         >>> overlays = document.findall('overlay') + document.findall('repo')
         >>> a = Overlay(overlays[0], dict())
         >>> a.name
@@ -101,10 +97,19 @@ class Overlay(object):
         >>> b.is_official()
         False
         '''
-
+        self.config = config
         self.output = config['output']
         self._encoding_ = get_encoding(self.output)
 
+        if xml:
+            self.from_xml(xml, ignore, quiet)
+        elif ovl_dict:
+            self.from_dict(ovl_dict, ignore, quiet)
+
+
+    def from_xml(self, xml, ignore, quiet):
+        """Process an xml overlay definition
+        """
         def strip_text(node):
             res = node.text
             if res is None:
@@ -128,10 +133,6 @@ class Overlay(object):
             _sources = [s]
             del s
 
-        if not _sources:
-            raise Exception('Overlay "' + self.name + '" is missing a "source" entry!')
-
-
         def create_overlay_source(source_elem):
             _type = source_elem.attrib['type']
             try:
@@ -139,10 +140,22 @@ class Overlay(object):
             except KeyError:
                 raise Exception('Unknown overlay type "%s"!' % _type)
             _location = ensure_unicode(strip_text(source_elem))
-            return _class(self, xml, config, _location, ignore, quiet)
+            return _class(parent=self, config=self.config,
+                _location=_location, ignore=ignore, quiet=quiet)
+
+        if not _sources:
+            raise Exception('Overlay "' + self.name + \
+                '" is missing a "source" entry!')
 
         self.sources = [create_overlay_source(e) for e in _sources]
 
+        _subpath = xml.find('subpath')
+        if _subpath != None:
+            self.subpath = ensure_unicode(_subpath.text.strip())
+        elif 'subpath' in xml.attrib:
+            self.subpath = ensure_unicode(xml.attrib['subpath'])
+        else:
+            self.subpath = ''
 
         _owner = xml.find('owner')
         if _owner == None:
@@ -169,7 +182,6 @@ class Overlay(object):
                 self.output.warn('Overlay "' + self.name + '" is missing a '
                          '"owner.email" entry!', 4)
 
-
         _desc = xml.find('description')
         if _desc != None:
             d = WHITESPACE_REGEX.sub(' ', strip_text(_desc))
@@ -208,7 +220,8 @@ class Overlay(object):
         else:
             self.homepage = None
 
-        self.feeds = [ensure_unicode(strip_text(e)) for e in xml.findall('feed')]
+        self.feeds = [ensure_unicode(strip_text(e)) \
+            for e in xml.findall('feed')]
 
         _irc = xml.find('irc')
         if _irc != None:
@@ -217,6 +230,100 @@ class Overlay(object):
             self.irc = None
 
 
+    def from_dict(self, overlay, ignore, quiet):
+        """Process an xml overlay definition
+        """
+        print "overlay", overlay
+        _name = overlay['name']
+        if _name != None:
+            self.name = ensure_unicode(_name)
+        else:
+            raise Exception('Overlay is missing a "name" entry!')
+
+        _sources = overlay['sources']
+
+        if not _sources:
+            raise Exception('Overlay "' + self.name +
+                '" is missing a "source" entry!')
+
+        def create_dict_overlay_source(source_):
+            _src, _type, _sub = source_
+            try:
+                _class = OVERLAY_TYPES[_type]
+            except KeyError:
+                raise Exception('Unknown overlay type "%s"!' % _type)
+            _location = ensure_unicode(_src)
+            return _class(parent=self, config=self.config,
+                _location=_location, ignore=ignore, quiet=quiet)
+
+        self.sources = [create_dict_overlay_source(e) for e in _sources]
+
+        _owner = overlay['owner_name']
+        if _owner == None:
+            self.owner_name = None
+            _email = None
+        else:
+            self.owner_name = ensure_unicode(_owner)
+            _email = overlay['owner_email']
+        if _email != None:
+            self.owner_email = ensure_unicode(_email)
+        else:
+            self.owner_email = None
+            if not ignore:
+                raise Exception('Overlay "' + self.name + '" is missing a '
+                                '"owner.email" entry!')
+            elif ignore == 1:
+                self.output.warn('Overlay "' + self.name + '" is missing a '
+                         '"owner.email" entry!', 4)
+
+        _desc = overlay['description']
+        if _desc != None:
+            d = WHITESPACE_REGEX.sub(' ', _desc)
+            self.description = ensure_unicode(d)
+            del d
+        else:
+            self.description = ''
+            if not ignore:
+                raise Exception('Overlay "' + self.name + '" is missing a '
+                        '"description" entry!')
+            elif ignore == 1:
+                self.output.warn('Overlay "' + self.name + '" is missing a '
+                         '"description" entry!', 4)
+
+        if overlay['status']:
+            self.status = ensure_unicode(overlay['status'])
+        else:
+            self.status = None
+
+        self.quality = u'experimental'
+        if overlay['quality']:
+            if overlay['quality'] in set(QUALITY_LEVELS):
+                self.quality = ensure_unicode(overlay['quality'])
+
+        if overlay['priority']:
+            self.priority = int(overlay['priority'])
+        else:
+            self.priority = 50
+
+        h = overlay['homepage']
+        if h != None:
+            self.homepage = ensure_unicode(h)
+        else:
+            self.homepage = None
+
+        self.feeds = [ensure_unicode(e) \
+            for e in overlay['feeds']]
+
+        _irc = overlay['irc']
+        if _irc != None:
+            self.irc = ensure_unicode(_irc)
+        else:
+            self.irc = None
+
+        #xml = self.to_xml()
+        # end of from_dict
+
+
     def __eq__(self, other):
         for i in ('description', 'homepage', 'name', 'owner_email',
                 'owner_name', 'priority', 'status'):
@@ -229,17 +336,18 @@ class Overlay(object):
                 return False
         return True
 
+
     def __ne__(self, other):
         return not self.__eq__(other)
 
+
     def set_priority(self, priority):
         '''Set the priority of this overlay.'''
-
         self.priority = int(priority)
 
+
     def to_xml(self):
         '''Convert to xml.'''
-
         repo = ET.Element('repo')
         if self.status != None:
             repo.attrib['status'] = self.status
@@ -284,6 +392,7 @@ class Overlay(object):
             del feed
         return repo
 
+
     def add(self, base, quiet = False):
         res = 1
         first_s = True
@@ -301,19 +410,22 @@ class Overlay(object):
             first_s = False
         return res
 
+
     def sync(self, base, quiet = False):
         assert len(self.sources) == 1
         return self.sources[0].sync(base, quiet)
 
+
     def delete(self, base):
         assert len(self.sources) == 1
         return self.sources[0].delete(base)
 
+
     def get_infostr(self):
         '''
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> import xml.etree.ElementTree as ET # Python 2.5
-        >>> document = ET.parse(here + '/../tests/testfiles/global-overlays.xml')
+        >>> document =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
         >>> overlays = document.findall('overlay') + document.findall('repo')
         >>> a = Overlay(overlays[0], dict())
         >>> print str(a)
@@ -342,13 +454,15 @@ class Overlay(object):
             result += '\n'
 
         if self.owner_name != None:
-            result += u'\nContact : %s <%s>' % (self.owner_name, self.owner_email)
+            result += u'\nContact : %s <%s>' \
+                % (self.owner_name, self.owner_email)
         else:
             result += u'\nContact : ' + self.owner_email
         if len(self.sources) == 1:
             result += u'\nType    : ' + self.sources[0].type
         else:
-            result += u'\nType    : ' + '/'.join(sorted(set(e.type for e in self.sources)))
+            result += u'\nType    : ' + '/'.join(
+                sorted(set(e.type for e in self.sources)))
         result += u'; Priority: ' + str(self.priority) + u'\n'
         result += u'Quality : ' + self.quality + u'\n'
 
@@ -379,17 +493,17 @@ class Overlay(object):
 
         return encoder(result, self._encoding_)
 
+
     def short_list(self, width = 0):
         '''
         >>> here = os.path.dirname(os.path.realpath(__file__))
         >>> import xml.etree.ElementTree as ET # Python 2.5
-        >>> document = ET.parse(here + '/../tests/testfiles/global-overlays.xml')
+        >>> document =ET.parse(here + '/../tests/testfiles/global-overlays.xml')
         >>> overlays = document.findall('repo') + document.findall('overlay')
         >>> a = Overlay(overlays[0], dict())
         >>> print a.short_list(80)
-        wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
+        wrobel             [Subversion] (https://o.g.o/svn/dev/wrobel         )
         '''
-
         name   = pad(self.name, 25)
 
         if len(set(e.type for e in self.sources)) == 1:
@@ -408,28 +522,31 @@ class Overlay(object):
 
         return encoder(name + mtype + source, self._encoding_)
 
+
     def is_official(self):
         '''Is the overlay official?'''
-
         return self.status == 'official'
 
+
     def is_supported(self):
         return any(e.is_supported() for e in self.sources)
 
+
     def source_uris(self):
         for i in self.sources:
             yield i.src
 
+
     def source_types(self):
         for i in self.sources:
             yield i.type
 
 
-#================================================================================
+#==============================================================================
 #
 # Testing
 #
-#--------------------------------------------------------------------------------
+#------------------------------------------------------------------------------
 
 if __name__ == '__main__':
     import doctest

diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 84836dd..1d6e831 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -40,9 +40,9 @@ class RsyncOverlay(OverlaySource):
     type_key = 'rsync'
 
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(RsyncOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
+        super(RsyncOverlay, self).__init__(parent, config, _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index b0bc9a3..586ec6c 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -53,13 +53,14 @@ class OverlaySource(object):
 
     type_key = None
 
-    def __init__(self, parent, xml, config, _location,
+    def __init__(self, parent, config, _location,
             ignore = 0, quiet = False):
         self.parent = parent
         self.src = _location
         self.config = config
         self.ignore = ignore
         self.quiet = quiet
+
         self.output = config['output']
 
     def __eq__(self, other):

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index c237ea4..147a641 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -39,11 +39,11 @@ class SvnOverlay(OverlaySource):
     type = 'Subversion'
     type_key = 'svn'
 
-    def __init__(self, parent, xml, config, _location,
+    def __init__(self, parent, config, _location,
             ignore = 0, quiet = False):
 
         super(SvnOverlay, self).__init__(
-            parent, xml,config, _location, ignore, quiet)
+            parent, config, _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 09ed979..5f1f606 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -73,17 +73,9 @@ class TarOverlay(OverlaySource):
     type = 'Tar'
     type_key = 'tar'
 
-    def __init__(self, parent, xml, config, _location, ignore = 0, quiet = False):
+    def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(TarOverlay, self).__init__(parent, xml, config, _location, ignore, quiet)
-
-        _subpath = xml.find('subpath')
-        if _subpath != None:
-            self.subpath = ensure_unicode(_subpath.text.strip())
-        elif 'subpath' in xml.attrib:
-            self.subpath = ensure_unicode(xml.attrib['subpath'])
-        else:
-            self.subpath = ''
+        super(TarOverlay, self).__init__(parent, config, _location, ignore, quiet)
 
         self.output = config['output']
 



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-27 10:58 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     a160cc7323338779f8f96e4b63da3e22742d9063
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Feb 24 07:05:45 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 27 02:39:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a160cc73

remove unused import.
change an exception into an output.error message.
set more functions to return True/False

---
 layman/overlays/source.py |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 586ec6c..be7b639 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -18,7 +18,6 @@ import copy
 import sys
 import shutil
 import subprocess
-#from layman.debug import OUT
 from layman.utils import path
 
 
@@ -75,10 +74,12 @@ class OverlaySource(object):
         mdir = path([base, self.parent.name])
 
         if os.path.exists(mdir):
-            raise Exception('Directory ' + mdir +
+            self.output.error('Directory ' + mdir +
                 ' already exists. Will not overwrite its contents!')
+            return False
 
         os.makedirs(mdir)
+        return True
 
     def sync(self, base, quiet = False):
         '''Sync the overlay.'''
@@ -91,10 +92,11 @@ class OverlaySource(object):
         if not os.path.exists(mdir):
             self.output.warn('Directory ' + mdir + \
                 ' did not exist, no files deleted.')
-            return
+            return false
 
         self.output.info('Deleting directory "%s"' % mdir, 2)
         shutil.rmtree(mdir)
+        return True
 
     def supported(self):
         '''Is the overlay type supported?'''



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-27 10:58 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     0a82306f384ab032a30cce35513a7a4a7c194991
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Feb 26 02:46:44 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 27 02:39:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0a82306f

replace more exception raising with error reporting and proper return values.
some long line cleanup.

---
 layman/overlays/bzr.py       |    5 +++--
 layman/overlays/cvs.py       |    5 +++--
 layman/overlays/darcs.py     |    8 +++++---
 layman/overlays/g_common.py  |   15 ++++++++-------
 layman/overlays/git.py       |    8 +++++---
 layman/overlays/mercurial.py |    5 +++--
 layman/overlays/rsync.py     |   13 ++++++++-----
 layman/overlays/source.py    |   23 ++++++++++-------------
 layman/overlays/svn.py       |    4 ++--
 layman/overlays/tar.py       |    7 +++++--
 10 files changed, 52 insertions(+), 41 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 1c2c702..957f9e7 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -84,5 +84,6 @@ class BzrOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'bzr',
-                                         'dev-vcs/bzr'),])
+        return require_supported(
+            [(self.command(),  'bzr', 'dev-vcs/bzr'),],
+            self.output.error)

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 2e76aa5..69e0dd1 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -109,5 +109,6 @@ class CvsOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'cvs',
-                                         'dev-vcs/cvs'),])
+        return require_supported(
+            [(self.command(),  'cvs', 'dev-vcs/cvs'),],
+            self.output.error)

diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 566d6ba..14a415b 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -42,7 +42,8 @@ class DarcsOverlay(OverlaySource):
 
     def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(DarcsOverlay, self).__init__(parent, config, _location, ignore, quiet)
+        super(DarcsOverlay, self).__init__(parent, config,
+            _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''
@@ -84,5 +85,6 @@ class DarcsOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'darcs',
-                                         'dev-vcs/darcs'),])
+        return require_supported(
+            [(self.command(),  'darcs', 'dev-vcs/darcs'),],
+            self.output.error)

diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index 5be191d..fae11df 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -39,7 +39,8 @@ class GCommonOverlay(OverlaySource):
     type_key = 'g-common'
 
     def __init__(self, parent, config, _location, ignore = 0, quiet = False):
-        super(GCommonOverlay, self).__init__(parent, config, _location, ignore, quiet)
+        super(GCommonOverlay, self).__init__(parent, config,
+            _location, ignore, quiet)
         #split source into driver and remote uri.
         self.driver=self.src[:self.src.find(' ')]
         self.remote_uri=self.src[self.src.find(' ')+1:]
@@ -73,9 +74,9 @@ class GCommonOverlay(OverlaySource):
         '''Overlay type supported?'''
 
         return require_supported(
-                                [(self.command(),
-                                'g-common',
-                                'app-portage/g-common'),
-                                ('/usr/share/g-common/drivers/'+self.driver+'.cfg',
-                                'g-common for '+self.driver,
-                                'app-portage/g-'+self.driver),])
+            [(self.command(),
+            'g-common',
+            'app-portage/g-common'),
+            ('/usr/share/g-common/drivers/'+self.driver+'.cfg',
+            'g-common for '+self.driver,
+            'app-portage/g-'+self.driver),], self.output.error)

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 0c0404f..d65a5d3 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -46,7 +46,8 @@ class GitOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return False
 
         def fix_git_source(source):
             # http:// should get trailing slash, other protocols shouldn't
@@ -89,5 +90,6 @@ class GitOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'git',
-                                         'dev-vcs/git'),])
+        return require_supported(
+            [(self.command(),  'git', 'dev-vcs/git'),],
+            self.output.error)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 1d0cb92..748588b 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -85,5 +85,6 @@ class MercurialOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'mercurial',
-                                         'dev-vcs/mercurial'),])
+        return require_supported(
+            [(self.command(),  'mercurial', 'dev-vcs/mercurial'),],
+            self.output.error)

diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 1d6e831..76b289e 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -42,7 +42,8 @@ class RsyncOverlay(OverlaySource):
 
     def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(RsyncOverlay, self).__init__(parent, config, _location, ignore, quiet)
+        super(RsyncOverlay, self).__init__(parent, config,
+            _location, ignore, quiet)
 
     def add(self, base, quiet = False):
         '''Add overlay.'''
@@ -59,8 +60,9 @@ class RsyncOverlay(OverlaySource):
         self.supported()
 
         # rsync OPTIONS [-q] SOURCE TARGET
-        args = ['-rlptDvz', '--progress', '--delete', '--delete-after', '--timeout=180',
-            '--exclude=distfiles/*', '--exclude=local/*', '--exclude=packages/*']
+        args = ['-rlptDvz', '--progress', '--delete', '--delete-after',
+            '--timeout=180', '--exclude=distfiles/*', '--exclude=local/*',
+            '--exclude=packages/*']
 
         cfg_opts = self.config["rsync_syncopts"]
         target = path([base, self.parent.name])
@@ -79,5 +81,6 @@ class RsyncOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'rsync',
-                                         'net-misc/rsync'),])
+        return require_supported(
+            [(self.command(),  'rsync', 'net-misc/rsync'),],
+            self.output.error)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index be7b639..b88131f 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -21,10 +21,11 @@ import subprocess
 from layman.utils import path
 
 
-def _resolve_command(command):
+def _resolve_command(command, error_output):
     if os.path.isabs(command):
         if not os.path.exists(command):
-            raise Exception('Program "%s" not found' % command)
+            error_output('Program "%s" not found' % command)
+            return ('File', None)
         return ('File', command)
     else:
         kind = 'Command'
@@ -33,18 +34,19 @@ def _resolve_command(command):
             f = os.path.join(d, command)
             if os.path.exists(f):
                 return ('Command', f)
-        raise Exception('Cound not resolve command ' +\
+        error_output('Cound not resolve command ' +\
             '"%s" based on PATH "%s"' % (command, env_path))
+        return ('Command', None)
 
 
-def require_supported(binaries):
+def require_supported(binaries, error_output):
     for command, mtype, package in binaries:
-        found = False
-        kind, path = _resolve_command(command)
+        kind, path = _resolve_command(command, error_output)
         if not path:
-            raise Exception(kind + ' ' + command + ' seems to be missing!'
+            error_output(kind + ' ' + command + ' seems to be missing!'
                             ' Overlay type "' + mtype + '" not support'
                             'ed. Did you emerge ' + package + '?')
+            return False
     return True
 
 
@@ -104,12 +106,7 @@ class OverlaySource(object):
 
     def is_supported(self):
         '''Is the overlay type supported?'''
-
-        try:
-            self.supported()
-            return True
-        except:
-            return False
+        return self.supported()
 
     def command(self):
         return self.config['%s_command' % self.__class__.type_key]

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 147a641..e0eb632 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -99,5 +99,5 @@ class SvnOverlay(OverlaySource):
         '''Overlay type supported?'''
 
         return require_supported(
-            [(self.command(),  'svn','dev-vcs/subversion'),]
-        )
+            [(self.command(),  'svn','dev-vcs/subversion'),],
+            self.output.error)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 5f1f606..9d59b71 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -75,7 +75,8 @@ class TarOverlay(OverlaySource):
 
     def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
-        super(TarOverlay, self).__init__(parent, config, _location, ignore, quiet)
+        super(TarOverlay, self).__init__(parent,
+            config, _location, ignore, quiet)
 
         self.output = config['output']
 
@@ -199,7 +200,9 @@ class TarOverlay(OverlaySource):
     def supported(self):
         '''Overlay type supported?'''
 
-        return require_supported([(self.command(),  'tar', 'app-arch/tar'), ])
+        return require_supported(
+            [(self.command(),  'tar', 'app-arch/tar'), ],
+            self.output.error)
 
 if __name__ == '__main__':
     import doctest



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-27 10:58 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     d73b5dacce0927e727db5aebb9384a6fd2bb1cd5
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Mar 27 03:23:02 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 27 03:23:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d73b5dac

fix missed parameter.

---
 layman/overlays/source.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index b88131f..458f627 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -112,7 +112,7 @@ class OverlaySource(object):
         return self.config['%s_command' % self.__class__.type_key]
 
     def run_command(self, command, *args, **kwargs):
-        file_to_run = _resolve_command(command)[1]
+        file_to_run = _resolve_command(command, self.output.error)[1]
         args = (file_to_run, ) + args
         assert('pwd' not in kwargs)  # Bug detector
 



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-27 10:58 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-27 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     eab52f261bda8aef53675271357b3ca742f865ad
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Mar 27 07:14:16 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar 27 07:14:16 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=eab52f26

migrate to explicit if check

---
 layman/overlays/overlay.py |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index b99c052..9486c38 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -101,9 +101,9 @@ class Overlay(object):
         self.output = config['output']
         self._encoding_ = get_encoding(self.output)
 
-        if xml:
+        if xml is not None:
             self.from_xml(xml, ignore, quiet)
-        elif ovl_dict:
+        elif ovl_dict is not None:
             self.from_dict(ovl_dict, ignore, quiet)
 
 
@@ -125,7 +125,7 @@ class Overlay(object):
             raise Exception('Overlay is missing a "name" entry!')
 
         _sources = xml.findall('source')
-        if _sources:
+        if _sources != None:
             _sources = [e for e in _sources if 'type' in e.attrib]
         elif ('src' in xml.attrib) and ('type' in xml.attrib):
             s = ET.Element('source', type=xml.attrib['type'])
@@ -242,7 +242,7 @@ class Overlay(object):
 
         _sources = overlay['sources']
 
-        if not _sources:
+        if _sources == None:
             raise Exception('Overlay "' + self.name +
                 '" is missing a "source" entry!')
 
@@ -296,7 +296,7 @@ class Overlay(object):
             self.status = None
 
         self.quality = u'experimental'
-        if overlay['quality']:
+        if len(overlay['quality']):
             if overlay['quality'] in set(QUALITY_LEVELS):
                 self.quality = ensure_unicode(overlay['quality'])
 
@@ -485,7 +485,7 @@ class Overlay(object):
         if self.irc != None:
             result += u'\nIRC : ' + self.irc + u'\n'
 
-        if self.feeds:
+        if len(self.feeds):
             result += u'\n%s:' % ((len(self.feeds) == 1) and "Feed" or "Feeds")
             for i in self.feeds:
                 result += u'\n  %s' % i



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-30  6:37 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-30  6:37 UTC (permalink / raw
  To: gentoo-commits

commit:     51424bf1f0aa7734dfc45672a5c6ae9ef10cbb6e
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Apr 30 06:35:32 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Apr 30 06:35:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=51424bf1

Fix supported() use to return 1 if it is not supported.
This is a continuation of the move away from raising exceptions for everything.

---
 layman/overlays/bzr.py       |    6 ++++--
 layman/overlays/cvs.py       |    6 ++++--
 layman/overlays/darcs.py     |    6 ++++--
 layman/overlays/g_common.py  |    8 ++++++--
 layman/overlays/git.py       |    6 ++++--
 layman/overlays/mercurial.py |    6 ++++--
 layman/overlays/rsync.py     |    6 ++++--
 layman/overlays/svn.py       |    6 ++++--
 layman/overlays/tar.py       |    8 ++++++--
 9 files changed, 40 insertions(+), 18 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index ec57a7b..af313ef 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -49,7 +49,8 @@ class BzrOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["bzr_addopts"]
         target = path([base, self.parent.name])
@@ -67,7 +68,8 @@ class BzrOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["bzr_syncopts"]
         target = path([base, self.parent.name])

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index 15a6c97..edf164c 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -65,7 +65,8 @@ class CvsOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["cvs_addopts"]
         target = path([base, self.parent.name])
@@ -89,7 +90,8 @@ class CvsOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["cvs_syncopts"]
         target = path([base, self.parent.name])

diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index 358db2d..ce1dbb7 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -48,7 +48,8 @@ class DarcsOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["darcs_addopts"]
         target = path([base, self.parent.name])
@@ -68,7 +69,8 @@ class DarcsOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["darcs_addopts"]
         target = path([base, self.parent.name])

diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index fae11df..85b079b 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -48,7 +48,9 @@ class GCommonOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
+
         target = path([base, self.parent.name])
 
         os.makedirs(target)
@@ -58,7 +60,9 @@ class GCommonOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
+
         target = path([base, self.parent.name])
 
         args = [target, 'sync', self.driver, self.remote_uri]

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 1825f92..3ded205 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -47,7 +47,7 @@ class GitOverlay(OverlaySource):
         '''Add overlay.'''
 
         if not self.supported():
-            return False
+            return 1
 
         def fix_git_source(source):
             # http:// should get trailing slash, other protocols shouldn't
@@ -73,7 +73,8 @@ class GitOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["git_syncopts"]
         target = path([base, self.parent.name])
@@ -83,6 +84,7 @@ class GitOverlay(OverlaySource):
             args.append('-q')
         if len(cfg_opts):
             args.append(cfg_opts)
+
         return self.postsync(
             self.run_command(self.command(), *args, cwd=target, cmd=self.type),
             cwd=target)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index c6a9fce..53d73e9 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -49,7 +49,8 @@ class MercurialOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["mercurial_addopts"]
         target = path([base, self.parent.name])
@@ -67,7 +68,8 @@ class MercurialOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         cfg_opts = self.config["mercurial_syncopts"]
         target = path([base, self.parent.name])

diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index d282b35..8243c09 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -48,7 +48,8 @@ class RsyncOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         super(RsyncOverlay, self).add(base)
 
@@ -57,7 +58,8 @@ class RsyncOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         # rsync OPTIONS [-q] SOURCE TARGET
         args = ['-rlptDvz', '--progress', '--delete', '--delete-after',

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 6b124a3..7e27d12 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -48,7 +48,8 @@ class SvnOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         super(SvnOverlay, self).add(base)
 
@@ -70,7 +71,8 @@ class SvnOverlay(OverlaySource):
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         def checkout_location():
             # Append '@' iff needed

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 204a626..a759332 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -176,7 +176,8 @@ class TarOverlay(OverlaySource):
     def add(self, base, quiet = False):
         '''Add overlay.'''
 
-        self.supported()
+        if not self.supported():
+            return 1
 
         target = path([base, self.parent.name])
 
@@ -190,7 +191,10 @@ class TarOverlay(OverlaySource):
 
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
-        self.supported()
+
+        if not self.supported():
+            return 1
+
         target = path([base, self.parent.name])
 
         return self.postsync(



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-04-30 22:37 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-04-30 22:37 UTC (permalink / raw
  To: gentoo-commits

commit:     1b94f151b74219541f87c8ec29b381c63075d07d
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Apr 30 07:01:30 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Apr 30 07:01:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=1b94f151

start moving to debug message types.

---
 layman/overlays/overlay.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 9d2006b..dd2437c 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -233,7 +233,7 @@ class Overlay(object):
     def from_dict(self, overlay, ignore, quiet):
         """Process an xml overlay definition
         """
-        print "overlay", overlay
+        self.output.debug("Overlay.from_dict; overlay" + str(overlay))
         _name = overlay['name']
         if _name != None:
             self.name = ensure_unicode(_name)



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-05-05  9:44 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-05-05  9:44 UTC (permalink / raw
  To: gentoo-commits

commit:     e55554e5b5c6a9c95bb8ad56aab195df1fb35817
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu May  5 09:42:07 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu May  5 09:42:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e55554e5

fix a regression for the old xml format.
improve the Exception messages with the function name it originated in.

---
 layman/overlays/overlay.py |   46 ++++++++++++++++++++++++-------------------
 1 files changed, 26 insertions(+), 20 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index dd2437c..d57fe22 100644
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -122,11 +122,14 @@ class Overlay(object):
         elif 'name' in xml.attrib:
             self.name = ensure_unicode(xml.attrib['name'])
         else:
-            raise Exception('Overlay is missing a "name" entry!')
+            raise Exception('Overlay from_xml(), "' + self.name + \
+                'is missing a "name" entry!')
 
         _sources = xml.findall('source')
-        if _sources != None:
+        # new xml format
+        if _sources != []:
             _sources = [e for e in _sources if 'type' in e.attrib]
+        #old xml format
         elif ('src' in xml.attrib) and ('type' in xml.attrib):
             s = ET.Element('source', type=xml.attrib['type'])
             s.text = xml.attrib['src']
@@ -138,13 +141,14 @@ class Overlay(object):
             try:
                 _class = OVERLAY_TYPES[_type]
             except KeyError:
-                raise Exception('Unknown overlay type "%s"!' % _type)
+                raise Exception('Overlay from_xml(), "' + self.name + \
+                    'Unknown overlay type "%s"!' % _type)
             _location = ensure_unicode(strip_text(source_elem))
             return _class(parent=self, config=self.config,
                 _location=_location, ignore=ignore, quiet=quiet)
 
         if not len(_sources):
-            raise Exception('Overlay "' + self.name + \
+            raise Exception('Overlay from_xml(), "' + self.name + \
                 '" is missing a "source" entry!')
 
         self.sources = [create_overlay_source(e) for e in _sources]
@@ -176,8 +180,8 @@ class Overlay(object):
             self.owner_email = ''
             self.owner_name = None
             if not ignore:
-                raise Exception('Overlay "' + self.name + '" is missing a '
-                                '"owner.email" entry!')
+                raise Exception('Overlay  from_xml(), "' + self.name + \
+                    '" is missing an "owner.email" entry!')
             elif ignore == 1:
                 self.output.warn('Overlay "' + self.name + '" is missing a '
                          '"owner.email" entry!', 4)
@@ -190,8 +194,8 @@ class Overlay(object):
         else:
             self.description = ''
             if not ignore:
-                raise Exception('Overlay "' + self.name + '" is missing a '
-                        '"description" entry!')
+                raise Exception('Overlay  from_xml(), "' + self.name + \
+                    '" is missing a description" entry!')
             elif ignore == 1:
                 self.output.warn('Overlay "' + self.name + '" is missing a '
                          '"description" entry!', 4)
@@ -233,17 +237,18 @@ class Overlay(object):
     def from_dict(self, overlay, ignore, quiet):
         """Process an xml overlay definition
         """
-        self.output.debug("Overlay.from_dict; overlay" + str(overlay))
+        self.output.debug("Overlay from_dict(); overlay" + str(overlay))
         _name = overlay['name']
         if _name != None:
             self.name = ensure_unicode(_name)
         else:
-            raise Exception('Overlay is missing a "name" entry!')
+            raise Exception('Overlay from_dict(), "' + self.name +
+                'is missing a "name" entry!')
 
         _sources = overlay['sources']
 
         if _sources == None:
-            raise Exception('Overlay "' + self.name +
+            raise Exception('Overlay from_dict(), "' + self.name +
                 '" is missing a "source" entry!')
 
         def create_dict_overlay_source(source_):
@@ -251,7 +256,8 @@ class Overlay(object):
             try:
                 _class = OVERLAY_TYPES[_type]
             except KeyError:
-                raise Exception('Unknown overlay type "%s"!' % _type)
+                raise Exception('Overlay from_dict(), "' + self.name +
+                    'Unknown overlay type "%s"!' % _type)
             _location = ensure_unicode(_src)
             return _class(parent=self, config=self.config,
                 _location=_location, ignore=ignore, quiet=quiet)
@@ -270,11 +276,11 @@ class Overlay(object):
         else:
             self.owner_email = None
             if not ignore:
-                raise Exception('Overlay "' + self.name + '" is missing a '
-                                '"owner.email" entry!')
+                raise Exception('Overlay from_dict(), "' + self.name +
+                    '" is missing an "owner.email" entry!')
             elif ignore == 1:
-                self.output.warn('Overlay "' + self.name + '" is missing a '
-                         '"owner.email" entry!', 4)
+                self.output.warn('Overlay from_dict(), "' + self.name +
+                    '" is missing an "owner.email" entry!', 4)
 
         _desc = overlay['description']
         if _desc != None:
@@ -284,11 +290,11 @@ class Overlay(object):
         else:
             self.description = ''
             if not ignore:
-                raise Exception('Overlay "' + self.name + '" is missing a '
-                        '"description" entry!')
+                raise Exception('Overlay from_dict(), "' + self.name +
+                    '" is missing a "description" entry!')
             elif ignore == 1:
-                self.output.warn('Overlay "' + self.name + '" is missing a '
-                         '"description" entry!', 4)
+                self.output.warn('Overlay from_dict(), "' + self.name +
+                    '" is missing a "description" entry!', 4)
 
         if overlay['status']:
             self.status = ensure_unicode(overlay['status'])



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-07-23  6:45 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-07-23  6:45 UTC (permalink / raw
  To: gentoo-commits

commit:     0fde69e7ef993c3e5cca925cef35c8c895cfd834
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sat Jul 23 06:44:26 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Jul 23 06:44:26 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0fde69e7

fix undefined 'subpath', update tests

---
 layman/overlays/cvs.py |    1 +
 layman/overlays/tar.py |   12 ++++++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index c6660d0..83981e5 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -44,6 +44,7 @@ class CvsOverlay(OverlaySource):
     def __init__(self, parent, config, _location, ignore = 0, quiet = False):
 
         super(CvsOverlay, self).__init__(parent, config, _location, ignore, quiet)
+        self.subpath = None
 
 
     def __eq__(self, other):

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index e6c0d45..dc2234a 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -57,15 +57,18 @@ class TarOverlay(OverlaySource):
     >>> subpath = ET.Element('subpath')
     >>> subpath.text = 'layman-test'
     >>> repo[:] = [repo_name, desc, owner, source, subpath]
-    >>> config = {'tar_command':'/bin/tar', 'output': Message()}
+    >>> from layman.config import BareConfig
+    >>> config = BareConfig()
     >>> testdir = os.tmpnam()
     >>> os.mkdir(testdir)
     >>> from layman.overlays.overlay import Overlay
     >>> a = Overlay(config, repo, quiet=False)
     >>> config['output'].set_colorize(False)
-    >>> a.add(testdir) #doctest: +ELLIPSIS
-    * Running... # /bin/tar -v -x -f...
-    >>> sorted(os.listdir(testdir + '/dummy'))
+    >>> a.add(testdir)
+    0
+    >>> os.listdir(testdir + '/dummy/')
+    ['layman-test']
+    >>> sorted(os.listdir(testdir + '/dummy/layman-test/'))
     ['app-admin', 'app-portage']
     >>> shutil.rmtree(testdir)
     '''
@@ -79,6 +82,7 @@ class TarOverlay(OverlaySource):
             config, _location, ignore, quiet)
 
         self.output = config['output']
+        self.subpath = None
 
     def __eq__(self, other):
         res = super(TarOverlay, self).__eq__(other) \



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-07-28 21:33 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-07-28 21:33 UTC (permalink / raw
  To: gentoo-commits

commit:     10dddbc5d9fb6d33d881f17ffb864c40b04ed31c
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Jul 28 21:31:13 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jul 28 21:31:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=10dddbc5

initialize subpath variable for consistency between the  overlay types.

---
 layman/overlays/bzr.py       |    1 +
 layman/overlays/darcs.py     |    1 +
 layman/overlays/g_common.py  |    1 +
 layman/overlays/git.py       |    1 +
 layman/overlays/mercurial.py |    1 +
 layman/overlays/rsync.py     |    1 +
 layman/overlays/svn.py       |    1 +
 7 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index b251559..5844176 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -45,6 +45,7 @@ class BzrOverlay(OverlaySource):
 
         super(BzrOverlay, self).__init__(parent,
             config, _location, ignore, quiet)
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index e566f9c..02ef3c7 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -44,6 +44,7 @@ class DarcsOverlay(OverlaySource):
 
         super(DarcsOverlay, self).__init__(parent, config,
             _location, ignore, quiet)
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/g_common.py b/layman/overlays/g_common.py
index 00635b3..df7c4a4 100644
--- a/layman/overlays/g_common.py
+++ b/layman/overlays/g_common.py
@@ -44,6 +44,7 @@ class GCommonOverlay(OverlaySource):
         #split source into driver and remote uri.
         self.driver=self.src[:self.src.find(' ')]
         self.remote_uri=self.src[self.src.find(' ')+1:]
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 0832699..5775277 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -42,6 +42,7 @@ class GitOverlay(OverlaySource):
     def __init__(self, parent, config, _location, ignore = 0, quiet = False):
         super(GitOverlay, self).__init__(parent, config,
             _location, ignore, quiet)
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 316590d..ebaf635 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -45,6 +45,7 @@ class MercurialOverlay(OverlaySource):
 
         super(MercurialOverlay, self).__init__(parent,
             config, _location, ignore, quiet)
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py
index 3090c77..f4537ed 100644
--- a/layman/overlays/rsync.py
+++ b/layman/overlays/rsync.py
@@ -44,6 +44,7 @@ class RsyncOverlay(OverlaySource):
 
         super(RsyncOverlay, self).__init__(parent, config,
             _location, ignore, quiet)
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index c64be62..59b6284 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -44,6 +44,7 @@ class SvnOverlay(OverlaySource):
 
         super(SvnOverlay, self).__init__(
             parent, config, _location, ignore, quiet)
+        self.subpath = None
 
     def add(self, base, quiet = False):
         '''Add overlay.'''



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-08-07  8:39 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-08-07  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     ccc08e81e134edd2b595b1dfe049b501f96cf0d4
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Aug  7 08:38:34 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug  7 08:38:34 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ccc08e81

run "svn cleanup..." for keyboard interrupts, bug 377035 

---
 layman/overlays/source.py |    9 +++++++++
 layman/overlays/svn.py    |   22 ++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index a57baf4..71e75fc 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -126,10 +126,12 @@ class OverlaySource(object):
         return self.config['%s_command' % self.__class__.type_key]
 
     def run_command(self, command, args, **kwargs):
+        self.output.debug("OverlaySource.run_command(): " + command, 6)
         file_to_run = _resolve_command(command, self.output.error)[1]
         args = [file_to_run] + args
         assert('pwd' not in kwargs)  # Bug detector
 
+        self.output.debug("OverlaySource.run_command(): cleared 'assert'", 7)
         cwd = kwargs.get('cwd', None)
         env = None
         env_updates = None
@@ -172,6 +174,8 @@ class OverlaySource(object):
             result = proc.wait()
         except KeyboardInterrupt:
             self.output.info('Interrupted manually', 2)
+            self.output.warn("Checking for cleanup actions to perform", 4)
+            self.cleanup()
             result = 1
         except Exception as err:
             self.output.error(
@@ -207,3 +211,8 @@ class OverlaySource(object):
 
     def to_xml_hook(self, repo_elem):
         pass
+
+    def cleanup(self):
+        '''cleanup a failed/interrupted process
+        overridden in subclass if it is needed.'''
+        pass

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 97f03d6..cf867ae 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -55,7 +55,7 @@ class SvnOverlay(OverlaySource):
         super(SvnOverlay, self).add(base)
 
         cfg_opts = self.config["svn_addopts"]
-        target = path([base, self.parent.name])
+        self.target = path([base, self.parent.name])
 
         args = ['co']
         if quiet:
@@ -63,11 +63,11 @@ class SvnOverlay(OverlaySource):
         if len(cfg_opts):
             args.append(cfg_opts)
         args.append(self.src + '/@')
-        args.append(target)
+        args.append(self.target)
 
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
-            cwd=target)
+            cwd=self.target)
 
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
@@ -84,7 +84,7 @@ class SvnOverlay(OverlaySource):
             return path([base, repo_part])
 
         cfg_opts = self.config["svn_syncopts"]
-        target = checkout_location()
+        self.target = checkout_location()
 
         # svn up [-q] TARGET
         args = ['up']
@@ -92,11 +92,11 @@ class SvnOverlay(OverlaySource):
             args.append('-q')
         if len(cfg_opts):
             args.append(cfg_opts)
-        args.append(target)
+        args.append(self.target)
 
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
-            cwd=target)
+            cwd=self.target)
 
     def supported(self):
         '''Overlay type supported?'''
@@ -104,3 +104,13 @@ class SvnOverlay(OverlaySource):
         return require_supported(
             [(self.command(),  'svn','dev-vcs/subversion'),],
             self.output.warn)
+
+    def cleanup(self):
+        '''Code to run in the event of a keyboard interrupt.
+        runs svn cleanup
+        '''
+        self.output.warn("SVN: preparing to run cleanup()", 2)
+        args = ["cleanup"]
+        args.append(self.target)
+        cleanup = self.run_command(self.command(), args, cmd=self.type)
+        return



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-08-07  8:47 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-08-07  8:47 UTC (permalink / raw
  To: gentoo-commits

commit:     acc9c9163a0ff4fe3e19e4cb49228b93f1c5999e
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Aug  7 08:38:34 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug  7 08:47:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=acc9c916

run "svn cleanup..." for keyboard interrupts, bug 377035

---
 layman/overlays/source.py |    9 +++++++++
 layman/overlays/svn.py    |   22 ++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index a57baf4..71e75fc 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -126,10 +126,12 @@ class OverlaySource(object):
         return self.config['%s_command' % self.__class__.type_key]
 
     def run_command(self, command, args, **kwargs):
+        self.output.debug("OverlaySource.run_command(): " + command, 6)
         file_to_run = _resolve_command(command, self.output.error)[1]
         args = [file_to_run] + args
         assert('pwd' not in kwargs)  # Bug detector
 
+        self.output.debug("OverlaySource.run_command(): cleared 'assert'", 7)
         cwd = kwargs.get('cwd', None)
         env = None
         env_updates = None
@@ -172,6 +174,8 @@ class OverlaySource(object):
             result = proc.wait()
         except KeyboardInterrupt:
             self.output.info('Interrupted manually', 2)
+            self.output.warn("Checking for cleanup actions to perform", 4)
+            self.cleanup()
             result = 1
         except Exception as err:
             self.output.error(
@@ -207,3 +211,8 @@ class OverlaySource(object):
 
     def to_xml_hook(self, repo_elem):
         pass
+
+    def cleanup(self):
+        '''cleanup a failed/interrupted process
+        overridden in subclass if it is needed.'''
+        pass

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 97f03d6..b9a5a34 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -55,7 +55,7 @@ class SvnOverlay(OverlaySource):
         super(SvnOverlay, self).add(base)
 
         cfg_opts = self.config["svn_addopts"]
-        target = path([base, self.parent.name])
+        self.target = path([base, self.parent.name])
 
         args = ['co']
         if quiet:
@@ -63,11 +63,11 @@ class SvnOverlay(OverlaySource):
         if len(cfg_opts):
             args.append(cfg_opts)
         args.append(self.src + '/@')
-        args.append(target)
+        args.append(self.target)
 
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
-            cwd=target)
+            cwd=self.target)
 
     def sync(self, base, quiet = False):
         '''Sync overlay.'''
@@ -84,7 +84,7 @@ class SvnOverlay(OverlaySource):
             return path([base, repo_part])
 
         cfg_opts = self.config["svn_syncopts"]
-        target = checkout_location()
+        self.target = checkout_location()
 
         # svn up [-q] TARGET
         args = ['up']
@@ -92,11 +92,11 @@ class SvnOverlay(OverlaySource):
             args.append('-q')
         if len(cfg_opts):
             args.append(cfg_opts)
-        args.append(target)
+        args.append(self.target)
 
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
-            cwd=target)
+            cwd=self.target)
 
     def supported(self):
         '''Overlay type supported?'''
@@ -104,3 +104,13 @@ class SvnOverlay(OverlaySource):
         return require_supported(
             [(self.command(),  'svn','dev-vcs/subversion'),],
             self.output.warn)
+
+    def cleanup(self):
+        '''Code to run in the event of a keyboard interrupt.
+        runs svn cleanup
+        '''
+        self.output.warn("SVN: preparing to run cleanup()", 2)
+        args = ["cleanup"]
+        args.append(self.target)
+        cleanup = self.run_command(self.command(), args, cmd="svn cleanup")
+        return



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-09-05 16:09 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-09-05 16:09 UTC (permalink / raw
  To: gentoo-commits

commit:     6566ed3969a81d5d54cc17d9ec15ccef31ab9000
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Sep  5 16:08:42 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Sep  5 16:08:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6566ed39

fix bug 381853, remove the noise level param as error() does not have it like the other output functions. 

---
 layman/overlays/source.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 03bccc4..0f5c913 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -179,8 +179,8 @@ class OverlaySource(object):
             result = 1
         except Exception, err:
             self.output.error(
-                'Unknown exception running command: %s' % command_repr, 2)
-            self.output.error('Original error was: %s' % str(err), 2)
+                'Unknown exception running command: %s' % command_repr)
+            self.output.error('Original error was: %s' % str(err))
             result = 1
 
         if self.config['quiet']:



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-09-13 14:16 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-09-13 14:16 UTC (permalink / raw
  To: gentoo-commits

commit:     1a5291a46e9412c2cb784327f3e61f6dad217175
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Tue Sep 13 14:14:54 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 13 14:14:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=1a5291a4

fix typo, bug 382785

---
 layman/overlays/source.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 0f5c913..843edf4 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -104,7 +104,7 @@ class OverlaySource(object):
         if not os.path.exists(mdir):
             self.output.warn('Directory ' + mdir + \
                 ' did not exist, no files deleted.')
-            return false
+            return False
 
         self.output.info('Deleting directory "%s"' % mdir, 2)
         shutil.rmtree(mdir)



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-09-24  6:07 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-09-24  6:07 UTC (permalink / raw
  To: gentoo-commits

commit:     2413c2f4d2c5eb09063f477bcd158244ab8d32ff
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Sep 22 15:11:06 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 23 03:09:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=2413c2f4

fix bug 384085, deprecated "bzr get" to "bzr branch"

---
 layman/overlays/bzr.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 0fbd712..fb1fb24 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -58,10 +58,10 @@ class BzrOverlay(OverlaySource):
 
         # bzr get SOURCE TARGET
         if len(cfg_opts):
-            args = ['get', cfg_opts,
+            args = ['branch', cfg_opts,
                 self.src + '/', target]
         else:
-            args = ['get', self.src + '/', target]
+            args = ['branch', self.src + '/', target]
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2011-09-26  1:18 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2011-09-26  1:18 UTC (permalink / raw
  To: gentoo-commits

commit:     1160eeb2569486785c0568cd84090e4029cc0747
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Sep 26 01:17:11 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Sep 26 01:17:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=1160eeb2

fix a py3 failure, because the file was not opened in binary mode.

---
 layman/overlays/tar.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 5d66acc..c6f2443 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -118,7 +118,7 @@ class TarOverlay(OverlaySource):
         pkg = path([base, self.parent.name + ext])
 
         try:
-            out_file = open(pkg, 'w')
+            out_file = open(pkg, 'w+b')
             out_file.write(tar)
             out_file.close()
         except Exception, error:



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2012-01-06  8:16 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2012-01-06  8:16 UTC (permalink / raw
  To: gentoo-commits

commit:     77fd9c78984df218d33520c6dce7a8a0c630c456
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  6 08:14:20 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Jan  6 08:14:20 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=77fd9c78

Add cwd=base to git's add() run_command function call.  This fixes  Bug 396643 in selinux and newer git.

---
 layman/overlays/git.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 3cdc21e..308c81f 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -68,7 +68,10 @@ class GitOverlay(OverlaySource):
         args.append(fix_git_source(self.src))
         args.append(target)
         return self.postsync(
-            self.run_command(self.command(), args, cmd=self.type),
+            # adding cwd=base due to a new git bug in selinux due to
+            # not having user_home_dir_t and portage_fetch_t permissions
+            # but changing dir works around it.
+            self.run_command(self.command(), args, cmd=self.type, cwd=base),
             cwd=target)
 
     def sync(self, base):



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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2012-10-07 23:40 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2012-10-07 23:40 UTC (permalink / raw
  To: gentoo-commits

commit:     915e3c0865ecee24cb31ead94d573b397ae67c51
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  7 20:07:54 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Oct  7 20:07:54 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=915e3c08

fix traceback caused by an extra level parameter in the error _output() calls.  This caused the errors to not be printed.  Bug 390127.

---
 layman/overlays/source.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/layman/overlays/source.py b/layman/overlays/source.py
index 843edf4..2b79f2c 100644
--- a/layman/overlays/source.py
+++ b/layman/overlays/source.py
@@ -34,7 +34,7 @@ def _supported(key, check_supported=None):
 def _resolve_command(command, _output):
     if os.path.isabs(command):
         if not os.path.exists(command):
-            _output('Program "%s" not found' % command, 6)
+            _output('Program "%s" not found' % command)
             return ('File', None)
         return ('File', command)
     else:
@@ -45,7 +45,7 @@ def _resolve_command(command, _output):
             if os.path.exists(f):
                 return ('Command', f)
         _output('Cound not resolve command ' +\
-            '"%s" based on PATH "%s"' % (command, env_path), 6)
+            '"%s" based on PATH "%s"' % (command, env_path))
         return ('Command', None)
 
 
@@ -56,7 +56,7 @@ def require_supported(binaries, _output):
             if _output:
                 _output(kind + ' ' + command + ' seems to be missing!'
                             ' Overlay type "' + mtype + '" not support'
-                            'ed. Did you emerge ' + package + '?', 6)
+                            'ed. Did you emerge ' + package + '?')
             return False
     return True
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2012-10-08  4:36 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2012-10-08  4:36 UTC (permalink / raw
  To: gentoo-commits

commit:     fc3cd9942ac71e118796d823fe3303a8c7cecdc2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  8 04:33:51 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Oct  8 04:33:51 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=fc3cd994

An an automatic 'svn upgrade' capability for svn type repos.  Bug 408039.

---
 layman/overlays/svn.py |   39 +++++++++++++++++++++++++++++++++++++--
 1 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 3e5497c..9785025 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -18,14 +18,19 @@
 
 __version__ = "$Id: svn.py 236 2006-09-05 20:39:37Z wrobel $"
 
+
+import os
+from subprocess import PIPE, Popen
+
 #==============================================================================
 #
 # Dependencies
 #
 #------------------------------------------------------------------------------
 
-from   layman.utils             import path
-from   layman.overlays.source   import OverlaySource, require_supported
+from layman.utils           import path
+from layman.overlays.source import (OverlaySource, require_supported,
+    _resolve_command)
 
 #==============================================================================
 #
@@ -86,6 +91,10 @@ class SvnOverlay(OverlaySource):
         cfg_opts = self.config["svn_syncopts"]
         self.target = checkout_location()
 
+        # first check if an svn upgrade is needed.
+        self.output.debug("SVN: check_upgrade() call", 4)
+        self.check_upgrade(path([base, self.parent.name]))
+
         # svn up [-q] TARGET
         args = ['up']
         if self.config['quiet']:
@@ -114,3 +123,29 @@ class SvnOverlay(OverlaySource):
         args.append(self.target)
         cleanup = self.run_command(self.command(), args, cmd="svn cleanup")
         return
+
+    def check_upgrade(self, target):
+        '''Code to check the installed svn version and
+        run "svn upgrade" if needed.'''
+        file_to_run = _resolve_command(self.command(), self.output.error)[1]
+        args = file_to_run + ' -q --version'
+        pipe = Popen(args, shell=True, stdout=PIPE)
+        if pipe:
+            self.output.debug("SVN: check_upgrade()... have a valid pipe", 4)
+            version = pipe.stdout.readline().strip('\n')
+            self.output.debug("SVN: check_upgrade()... svn version found: %s"
+                % version, 4)
+            pipe.terminate()
+            if version >= '1.7.0':
+                self.output.debug("SVN: check_upgrade()... svn upgrade maybe",
+                    4)
+                _path = path([target,'.svn/wc.db'])
+                if not os.path.exists(_path):
+                    self.output.info("An svn upgrade needs to be run...",
+                        2)
+                    args = ["upgrade"]
+                    return self.run_command(self.command(), args,
+                        cwd=target, cmd="svn upgrade")
+                return
+        else:
+            return


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2012-10-08  6:16 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2012-10-08  6:16 UTC (permalink / raw
  To: gentoo-commits

commit:     729923d4a2d5a22f6509de438953ef6035d38e20
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Oct  8 06:15:51 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Oct  8 06:15:51 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=729923d4

Fix bug 372583.  Don't add redundant trailing slashes on src uri's where trailing slashes are required.

---
 layman/overlays/bzr.py       |    9 +++++++--
 layman/overlays/darcs.py     |    9 +++++++--
 layman/overlays/git.py       |    5 ++++-
 layman/overlays/mercurial.py |    9 +++++++--
 layman/overlays/svn.py       |    8 +++++++-
 5 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index fb1fb24..5bda251 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -56,12 +56,17 @@ class BzrOverlay(OverlaySource):
         cfg_opts = self.config["bzr_addopts"]
         target = path([base, self.parent.name])
 
+        if self.src.endswith("/"):
+            src = self.src
+        else:
+            src = self.src + '/'
+
         # bzr get SOURCE TARGET
         if len(cfg_opts):
             args = ['branch', cfg_opts,
-                self.src + '/', target]
+                src, target]
         else:
-            args = ['branch', self.src + '/', target]
+            args = ['branch', src, target]
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)

diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py
index d3eec6a..634681b 100644
--- a/layman/overlays/darcs.py
+++ b/layman/overlays/darcs.py
@@ -55,13 +55,18 @@ class DarcsOverlay(OverlaySource):
         cfg_opts = self.config["darcs_addopts"]
         target = path([base, self.parent.name])
 
+        if self.src.endswith("/"):
+            src = self.src
+        else:
+            src = self.src + '/'
+
         # darcs get --partial SOURCE TARGET
         if len(cfg_opts):
             args = ['get', '--partial', cfg_opts,
-                self.src + '/', target]
+                src, target]
         else:
             args = ['get', '--partial',
-                self.src + '/', target]
+                src, target]
 
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index e15f26d..81e650c 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -53,7 +53,10 @@ class GitOverlay(OverlaySource):
         def fix_git_source(source):
             # http:// should get trailing slash, other protocols shouldn't
             if source.split(':')[0] == 'http':
-                return source + '/'
+                if source.endswith('/'):
+                    return source
+                else:
+                    return source + '/'
             return source
 
         cfg_opts = self.config["git_addopts"]

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 0d8250e..5034993 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -56,11 +56,16 @@ class MercurialOverlay(OverlaySource):
         cfg_opts = self.config["mercurial_addopts"]
         target = path([base, self.parent.name])
 
+        if self.src.endswith("/"):
+            src = self.src
+        else:
+            src = self.src + '/'
+
         # hg clone SOURCE TARGET
         if len(cfg_opts):
-            args = ['clone', cfg_opts, self.src + '/', target]
+            args = ['clone', cfg_opts, src, target]
         else:
-            args = ['clone', self.src + '/', target]
+            args = ['clone', src, target]
 
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 9785025..4804925 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -67,7 +67,13 @@ class SvnOverlay(OverlaySource):
             args.append('-q')
         if len(cfg_opts):
             args.append(cfg_opts)
-        args.append(self.src + '/@')
+
+        if self.src.endswith("/"):
+            src = self.src + '@'
+        else:
+            src = self.src + '/@'
+
+        args.append(src)
         args.append(self.target)
 
         return self.postsync(


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2012-11-01  7:06 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2012-11-01  7:06 UTC (permalink / raw
  To: gentoo-commits

commit:     599442ca69c94f236132443ce8a5c24fa05fcdc1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Nov  1 07:05:10 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Nov  1 07:05:10 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=599442ca

fix bug 440628 truncated overlay names.

---
 layman/overlays/overlay.py |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8eb0870..f2cfc92 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -516,7 +516,11 @@ class Overlay(object):
         >>> print a.short_list(80)
         wrobel                    [Subversion] (https://o.g.o/svn/dev/wrobel         )
         '''
-        name   = pad(self.name, 25)
+        if len(self.name) > 25:
+            name = self.name + "   ###\n"
+            name += pad(" ", 25)
+        else:
+            name   = pad(self.name, 25)
 
         if len(set(e.type for e in self.sources)) == 1:
             _type = self.sources[0].type


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2013-08-18 16:46 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2013-08-18 16:46 UTC (permalink / raw
  To: gentoo-commits

commit:     ba8904daac17dfa504b89dd27df19e4526fd7c7f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 18 16:45:20 2013 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Aug 18 16:45:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ba8904da

add missed g_sourcery.py file in last commit

---
 layman/overlays/g_sorcery.py | 91 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/layman/overlays/g_sorcery.py b/layman/overlays/g_sorcery.py
new file mode 100644
index 0000000..b35111c
--- /dev/null
+++ b/layman/overlays/g_sorcery.py
@@ -0,0 +1,91 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#################################################################################
+# LAYMAN G-SORCERY OVERLAY HANDLER
+#################################################################################
+# File:       g_sorcery.py
+#
+#             Handles repositories generated by g-sorcery backends
+#
+# Copyright:
+#             (c) 2013 Gentoo Foundation
+#             Distributed under the terms of the GNU General Public License v2
+#
+# Author(s):
+#             Jauhien Piatlicki <piatlicki@gmail.com>
+#             Auke Booij <auke@tulcod.com>
+#
+''' g-sorcery repository support.'''
+
+#===============================================================================
+#
+# Dependencies
+#
+#-------------------------------------------------------------------------------
+
+import os
+from   layman.utils             import path
+from   layman.overlays.source   import OverlaySource, require_supported
+
+#===============================================================================
+#
+# Class GSorceryOverlay
+#
+#-------------------------------------------------------------------------------
+
+class GSorceryOverlay(OverlaySource):
+    ''' Handles g-sorcery repositories.'''
+
+    type = 'g-sorcery'
+    type_key = 'g-sorcery'
+
+    def __init__(self, parent, config, _location, ignore = 0):
+        super(GSorceryOverlay, self).__init__(parent, config,
+            _location, ignore)
+        #split source into backend and repository.
+        self.backend=self.src[:self.src.find(' ')]
+        self.repository=self.src[self.src.find(' ')+1:]
+        self.subpath = None
+
+    def add(self, base):
+        '''Add overlay.'''
+
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+
+        os.makedirs(target)
+
+        return self.sync(base)
+
+    def sync(self, base):
+        '''Sync overlay.'''
+
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+
+        args = [self.backend, '-o', target, '-r', self.repository, 'sync']
+        returncode = self.run_command(self.command(), args, cwd=target)
+        if returncode:
+            return returncode
+        args = [self.backend, '-o', target, 'generate-tree']
+        return self.postsync(
+            self.run_command(self.command(), args, cwd=target, cmd=self.type),
+            cwd=target)
+
+    def supported(self):
+        '''Overlay type supported?'''
+
+        return require_supported(
+            [(self.command(),
+             'g-sorcery',
+             'app-portage/g-sorcery'),
+
+             ('/usr/bin/' + self.backend,
+              self.backend,
+              'app-portage/' + self.backend),],
+
+              self.output.warn)


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2014-03-10  3:18 Brian Dolbec
  0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-03-10  3:18 UTC (permalink / raw
  To: gentoo-commits

commit:     8f96019f53b570163ddcf255551595fedca42bf4
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  7 06:01:12 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Mar 10 03:16:58 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=8f96019f

Update svn's check_upgrade() for newer svn versions.

Add stderr=PIPE to silence any error messages from less than svn ver. 1.8.

zzzd

---
 layman/overlays/svn.py | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 4804925..20c09fb 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -131,27 +131,19 @@ class SvnOverlay(OverlaySource):
         return
 
     def check_upgrade(self, target):
-        '''Code to check the installed svn version and
-        run "svn upgrade" if needed.'''
+        '''Code to run "svn upgrade" it only takes longer
+        than checking if it does need an upgrade if it is
+        actually needed.
+        '''
         file_to_run = _resolve_command(self.command(), self.output.error)[1]
-        args = file_to_run + ' -q --version'
-        pipe = Popen(args, shell=True, stdout=PIPE)
+        args = " ".join([file_to_run, " upgrade", target])
+        pipe = Popen(args, shell=True, stdout=PIPE, stderr=PIPE)
         if pipe:
-            self.output.debug("SVN: check_upgrade()... have a valid pipe", 4)
-            version = pipe.stdout.readline().strip('\n')
-            self.output.debug("SVN: check_upgrade()... svn version found: %s"
-                % version, 4)
+            self.output.debug("SVN: check_upgrade()... have a valid pipe, "
+                "running upgrade", 4)
+            upgrade_output = pipe.stdout.readline().strip('\n')
+            if upgrade_output:
+                self.output.debug("  output: %s" % upgrade_output, 4)
+            self.output.debug("SVN: check_upgrade()... svn upgrade done", 4)
             pipe.terminate()
-            if version >= '1.7.0':
-                self.output.debug("SVN: check_upgrade()... svn upgrade maybe",
-                    4)
-                _path = path([target,'.svn/wc.db'])
-                if not os.path.exists(_path):
-                    self.output.info("An svn upgrade needs to be run...",
-                        2)
-                    args = ["upgrade"]
-                    return self.run_command(self.command(), args,
-                        cwd=target, cmd="svn upgrade")
-                return
-        else:
-            return
+        return


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

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

commit:     ef6f5893a333684f3b73e04e486b02b60559c512
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon May 26 22:22:33 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=ef6f5893

svn.py: Adds update() function

Adds _fix_svn_source() function to correct the source url in
order to run the svn switch --relocate command.

---
 layman/overlays/svn.py | 37 ++++++++++++++++++++++++++++++++-----
 1 file changed, 32 insertions(+), 5 deletions(-)

diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py
index 0244dd4..f494eba 100644
--- a/layman/overlays/svn.py
+++ b/layman/overlays/svn.py
@@ -53,6 +53,18 @@ class SvnOverlay(OverlaySource):
             parent, config, _location, ignore)
         self.subpath = None
 
+    def _fix_svn_source(self, source):
+    '''
+    Adds @ to all sources that don't already include it.
+
+    @params source: source URL, string.
+    '''
+        if source.endswith("/"):
+            source = source + '@'
+        else:
+            source = source +'/@'
+        return source
+
     def add(self, base):
         '''Add overlay.'''
 
@@ -70,11 +82,7 @@ class SvnOverlay(OverlaySource):
         if len(cfg_opts):
             args.append(cfg_opts)
 
-        if self.src.endswith("/"):
-            src = self.src + '@'
-        else:
-            src = self.src + '/@'
-
+        src = self._fix_svn_source(self.src)
         args.append(src)
         args.append(self.target)
 
@@ -82,6 +90,25 @@ class SvnOverlay(OverlaySource):
             self.run_command(self.command(), args, cmd=self.type),
             cwd=self.target)
 
+    def update(self, base, src):
+        '''
+        Update overlay src-url
+        
+        @params base: base location where all overlays are installed.
+        @params src: source URL.
+        '''
+
+        self.output.debug("svn.update(); starting...%s" % self.parent.name, 6)
+        target = path([base, self.parent.name])
+
+        # svn switch --relocate <oldurl> <newurl>
+        args = ['switch', '--relocate', self._fix_svn_source(self.src), self._fix_svn_source(src)]
+
+        return self.postsync(
+             self.run_command(self.command(), args, cmd=self.type),
+             cwd=target)
+
+
     def sync(self, base):
         '''Sync overlay.'''
 


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

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

commit:     a4ce4f5a312c08eb90ccb741f673780b8559d0c4
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 23 21:33:47 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=a4ce4f5a

git.py: adds update() function

Moves the fix_git_source() function to allow both add() and update()
to make use of it. While the update() function calls git remote
set-url, replacing the old url with the new url provided by
overlay.update().

---
 layman/overlays/git.py | 38 ++++++++++++++++++++++++++++----------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index f3790ca..ee8c53b 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -46,21 +46,24 @@ class GitOverlay(OverlaySource):
             _location, ignore)
         self.subpath = None
 
+    def _fix_git_source(self, source):
+    '''
+    Adds trailing slash to http sources
+
+    @param source: source URL, string.
+    '''
+        # http:// should get trailing slash, other protocols shouldn't
+        if source.split(':')[:1] == 'http':
+            if not source.endswith('/'):
+                return source + '/'
+        return source
+
     def add(self, base):
         '''Add overlay.'''
 
         if not self.supported():
             return 1
 
-        def fix_git_source(source):
-            # http:// should get trailing slash, other protocols shouldn't
-            if source.split(':')[0] == 'http':
-                if source.endswith('/'):
-                    return source
-                else:
-                    return source + '/'
-            return source
-
         cfg_opts = self.config["git_addopts"]
         target = path([base, self.parent.name])
 
@@ -70,7 +73,7 @@ class GitOverlay(OverlaySource):
             args.append('-q')
         if len(cfg_opts):
             args.append(cfg_opts)
-        args.append(fix_git_source(self.src))
+        args.append(self._fix_git_source(self.src))
         args.append(target)
         success = False
         # adding cwd=base due to a new git bug in selinux due to
@@ -95,6 +98,21 @@ class GitOverlay(OverlaySource):
         self.output.debug("set git user info...args=%s" % ' '.join(args), 8)
         return self.run_command(self.command(), args, cmd=self.type, cwd=target)
 
+    def update(self, base, src):
+        '''
+        Update overlay src-url
+        
+        @params base: base location where all overlays are installed.
+        @params src:  source URL.
+        '''
+        self.output.debug("git.update(); starting...%s" % self.parent.name, 6)
+        target = path([base, self.parent.name])
+
+        # git remote set-url <name> <newurl> <oldurl>
+        args = ['remote', 'set-url', 'origin', self._fix_git_source(src), self._fix_git_source(self.src)]
+
+        return self.run_command(self.command(), args, cmd=self.type, cwd=target)
+
     def sync(self, base):
         '''Sync overlay.'''
 


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

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

commit:     323362ad64d9b0477a662c0d58eeec89e7e3948e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu May 29 23:12:58 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=323362ad

bzr.py: Adds update() function

Also adds _fix_brz_source() function to be used by add() and update().

---
 layman/overlays/bzr.py | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py
index 9cfa8b5..20d2491 100644
--- a/layman/overlays/bzr.py
+++ b/layman/overlays/bzr.py
@@ -49,6 +49,16 @@ class BzrOverlay(OverlaySource):
             config, _location, ignore)
         self.subpath = None
 
+    def _fix_bzr_source(self, source):
+    '''
+    Adds trailing slash to source URL if needed.
+
+    @params source: source URL, string.
+    '''
+        if source.endswith("/"):
+            return source
+        return source + '/'
+    
     def add(self, base):
         '''Add overlay.'''
 
@@ -58,10 +68,7 @@ class BzrOverlay(OverlaySource):
         cfg_opts = self.config["bzr_addopts"]
         target = path([base, self.parent.name])
 
-        if self.src.endswith("/"):
-            src = self.src
-        else:
-            src = self.src + '/'
+        src = self._fix_bzr_source(self.src)
 
         # bzr get SOURCE TARGET
         if len(cfg_opts):
@@ -73,6 +80,27 @@ class BzrOverlay(OverlaySource):
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)
 
+    def update(self, base, src):
+        '''
+        Updates overlay src-url.
+        
+        @params base: base location where all overlays are installed.
+        @params src: source URL.
+        '''
+
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+
+        # bzr bind SOURCE
+        args = ['bind', self._fix_bzr_source(src)]
+        if self.config['quiet']:
+            args.append('--quiet')
+        return self.postsync(
+            self.run_command(self.command(), args, cmd=self.type),
+            cwd=target)
+
     def sync(self, base):
         '''Sync overlay.'''
 


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

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

commit:     2c8417794872d797ef816760d5d9161c90f449fc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 30 01:19:52 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=2c841779

mercurial.py: Adds update() function

Also adds _fix_mercurial_source() function to be used by add() and update().

---
 layman/overlays/mercurial.py | 40 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 36 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index c188381..74f1934 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -27,6 +27,7 @@ __version__ = "$Id: mercurial.py 236 2006-09-05 20:39:37Z wrobel $"
 #
 #-------------------------------------------------------------------------------
 
+import re
 from   layman.utils             import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -49,6 +50,16 @@ class MercurialOverlay(OverlaySource):
             config, _location, ignore)
         self.subpath = None
 
+    def _fix_mercurial_source(self, source):
+    '''
+    Adds trailing slash to source URL if needed.
+
+    @params source: source URL, string.
+    '''
+        if source.endswith("/"):
+            return source
+        return source + '/'
+
     def add(self, base):
         '''Add overlay.'''
 
@@ -58,10 +69,7 @@ class MercurialOverlay(OverlaySource):
         cfg_opts = self.config["mercurial_addopts"]
         target = path([base, self.parent.name])
 
-        if self.src.endswith("/"):
-            src = self.src
-        else:
-            src = self.src + '/'
+        src = self._fix_mercurial_source(self.src)
 
         # hg clone SOURCE TARGET
         if len(cfg_opts):
@@ -73,6 +81,30 @@ class MercurialOverlay(OverlaySource):
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)
 
+    def update(self, base, src):
+        '''
+        Updates overlay src-url.
+        
+        @params base: base location where all overlays are installed.
+        @params src: source URL.
+        '''
+
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+        hgrc = ".hg/hgrc"
+
+        old_src = re.sub('/', '\/', self._fix_mercurial_source(self.src))
+        new_src = re.sub('/', '\/', self._fix_mercurial_source(src))
+        expression = "s/" + old_src + "/" + new_src + "/"
+
+        # sed -i 's/oldurl/newurl/' <target>/.hg/hgrc
+        args = ['-i', expression, hgrc]
+
+        # Run sed.
+        return self.run_command('sed', args, cmd='sed', cwd=target)
+
     def sync(self, base):
         '''Sync overlay.'''
 


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

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

commit:     e44f6726b5162cbc3026e9047878e2def78a562a
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri May 30 20:54:12 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=e44f6726

cvs.py: Adds update() function

---
 layman/overlays/cvs.py | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index b166dc8..bf54921 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -27,6 +27,7 @@ __version__ = "$Id$"
 #-------------------------------------------------------------------------------
 
 import xml.etree.ElementTree as ET # Python 2.5
+import re
 
 from   layman.utils             import path
 from   layman.overlays.source   import OverlaySource, require_supported
@@ -90,6 +91,42 @@ class CvsOverlay(OverlaySource):
                 env=dict(CVSROOT=self.src), cmd=self.type),
             cwd=target)
 
+    def update(self, base, src):
+        '''
+        Updates overlay src-url.
+        
+        @params base: base location where all overlays are installed.
+        @params src: source URL.
+        '''
+        
+        if not self.supported():
+            return 1
+
+        target = path([base, self.parent.name])
+        
+        # First echo the new repository to CVS/Root
+        args = [src, '>', '/CVS/Root']
+        result = self.run_command('echo', args, cmd='echo', cwd=target)
+
+        if result == 0:
+            location = src.split(':')[3]
+            old_location = self.src.split(':/')[3]
+    
+            # Check if the repository location needs to be updated too.
+            if not location == old_location:
+                location = re.sub('/', '\/', location)
+                old_location = re.sub('/', '\/', old_location)
+                
+                expression = 's/' + old_location + '/' + location + '/'
+
+                # sed -i 's/<old_location>/<new_location>/ <target>/CVS/Repository
+                args = ['-i', expression, '/CVS/Repository']
+
+                return self.run_command('sed', args, cmd='sed', cwd=target)
+
+        return result        
+        
+
     def sync(self, base):
         '''Sync overlay.'''
 


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

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

commit:     70e221ba1921d2275bbd415e20a5d9923d329b44
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 10 22:18:23 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 00:36:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=70e221ba

git.py: Adds module branch support

---
 layman/overlays/git.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/layman/overlays/git.py b/layman/overlays/git.py
index 2f4bd61..f3ada66 100644
--- a/layman/overlays/git.py
+++ b/layman/overlays/git.py
@@ -26,6 +26,8 @@ __version__ = "$Id: git.py 146 2006-05-27 09:52:36Z wrobel $"
 #
 #-------------------------------------------------------------------------------
 
+import xml.etree.ElementTree as ET
+
 from   layman.utils             import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -44,7 +46,7 @@ class GitOverlay(OverlaySource):
     def __init__(self, parent, config, _location, ignore = 0):
         super(GitOverlay, self).__init__(parent, config,
             _location, ignore)
-        self.branch = None
+        self.branch = self.parent.branch
 
 
     def _fix_git_source(self, source):
@@ -76,6 +78,10 @@ class GitOverlay(OverlaySource):
             args.append(cfg_opts)
         args.append(self._fix_git_source(self.src))
         args.append(target)
+
+        if self.branch:
+            args.append('-b')
+            args.append(self.branch)
         success = False
         # adding cwd=base due to a new git bug in selinux due to
         # not having user_home_dir_t and portage_fetch_t permissions


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

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

commit:     10881a57c8b438b4b4e984ebdb375d14fb63d474
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 11 05:22:51 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 00:36:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=10881a57

mercurial.py: Adds module branch support

---
 layman/overlays/mercurial.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py
index 7a5fe08..a1b7846 100644
--- a/layman/overlays/mercurial.py
+++ b/layman/overlays/mercurial.py
@@ -28,6 +28,8 @@ __version__ = "$Id: mercurial.py 236 2006-09-05 20:39:37Z wrobel $"
 #-------------------------------------------------------------------------------
 
 import re
+import xml.etree.ElementTree as ET
+
 from   layman.utils             import path
 from   layman.overlays.source   import OverlaySource, require_supported
 
@@ -48,7 +50,8 @@ class MercurialOverlay(OverlaySource):
 
         super(MercurialOverlay, self).__init__(parent,
             config, _location, ignore)
-        self.branch = None
+        self.branch = self.parent.branch
+
 
     def _fix_mercurial_source(self, source):
         '''
@@ -77,6 +80,10 @@ class MercurialOverlay(OverlaySource):
         else:
             args = ['clone', src, target]
 
+        if self.branch:
+            args.append('-r')
+            args.append(self.branch)
+
         return self.postsync(
             self.run_command(self.command(), args, cmd=self.type),
             cwd=target)


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

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

commit:     b5e16c46fd286a3df26923366dd2c4b0a4acaa9f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 11 18:43:08 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 00:36:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b5e16c46

{cvs, tar}.py: Fixes assignment for self.branch

Fixes commit: fix undefined 'subpath', update tests
SHA:0fde69e7ef993c3e5cca925cef35c8c895cfd834
Author: dol-sen <brian.dolbec <AT> gmail.com>
Date: Sat 23 Jul 2011 02:44:26 AM EDT

Fixes commit: removal of xml from the vcs class parameters.
SHA: ba5f0cd5c948bb7a65ab21008c940caf0fbe38e7
Author: Brian Dolbec <brian.dolbec <AT> gmail.com>
Date: Thu 24 Feb 2011 01:49:58 AM EST

---
 layman/overlays/cvs.py | 2 +-
 layman/overlays/tar.py | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py
index a8c6abb..70638e3 100644
--- a/layman/overlays/cvs.py
+++ b/layman/overlays/cvs.py
@@ -47,7 +47,7 @@ class CvsOverlay(OverlaySource):
     def __init__(self, parent, config, _location, ignore = 0):
 
         super(CvsOverlay, self).__init__(parent, config, _location, ignore)
-        self.branch = None
+        self.branch = self.parent.branch
 
 
     def add(self, base):

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index 884d527..acbeece 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -93,7 +93,7 @@ class TarOverlay(OverlaySource):
 
         self.output = config['output']
         self.proxies = config.proxies
-        self.branch = None
+        self.branch = self.parent.branch
 
 
     def _extract(self, base, tar_url, dest_dir):


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

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

commit:     a189742b6940cf15e078fd952c1fd9daa61951b0
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 12 21:42:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Jun 15 00:36:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=a189742b

tar.py: Adds file:// support for tar overlays

---
 layman/overlays/tar.py | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py
index fc15c56..e5d10b6 100644
--- a/layman/overlays/tar.py
+++ b/layman/overlays/tar.py
@@ -99,6 +99,7 @@ class TarOverlay(OverlaySource):
 
     def _extract(self, base, tar_url, dest_dir):
         ext = '.tar.noidea'
+        clean_tar = True
         for i in [('tar.%s' % e) for e in ('bz2', 'gz', 'lzma', 'xz', 'Z')] \
                 + ['tgz', 'tbz', 'taz', 'tlz', 'txz']:
             candidate_ext = '.%s' % i
@@ -106,33 +107,38 @@ class TarOverlay(OverlaySource):
                 ext = candidate_ext
                 break
 
-        # setup the ssl-fetch output map
-        connector_output = {
-            'info':  self.output.debug,
-            'error': self.output.error,
-            'kwargs-info': {'level': 2},
-            'kwargs-error':{'level': None},
-        }
+        if 'file://' not in tar_url:
+            # setup the ssl-fetch output map
+            connector_output = {
+                'info':  self.output.debug,
+                'error': self.output.error,
+                'kwargs-info': {'level': 2},
+                'kwargs-error':{'level': None},
+            }
 
-        fetcher = Connector(connector_output, self.proxies, USERAGENT)
+            fetcher = Connector(connector_output, self.proxies, USERAGENT)
 
-        success, tar, timestamp = fetcher.fetch_content(tar_url)
+            success, tar, timestamp = fetcher.fetch_content(tar_url)
 
-        pkg = path([base, self.parent.name + ext])
+            pkg = path([base, self.parent.name + ext])
 
-        try:
-            with fileopen(pkg, 'w+b') as out_file:
-                out_file.write(tar)
+            try:
+                with fileopen(pkg, 'w+b') as out_file:
+                    out_file.write(tar)
 
-        except Exception as error:
-            raise Exception('Failed to store tar package in '
-                            + pkg + '\nError was:' + str(error))
+            except Exception as error:
+                raise Exception('Failed to store tar package in '
+                                + pkg + '\nError was:' + str(error))
+        else:
+            clean_tar = False
+            pkg = tar_url.replace('file://', '')
 
         # tar -v -x -f SOURCE -C TARGET
         args = ['-v', '-x', '-f', pkg, '-C', dest_dir]
         result = self.run_command(self.command(), args, cmd=self.type)
 
-        os.unlink(pkg)
+        if clean_tar:
+            os.unlink(pkg)
         return result
 
     def _add_unchecked(self, base):


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2014-12-08  4:15 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2014-12-08  4:15 UTC (permalink / raw
  To: gentoo-commits

commit:     b6b75d3522151be7bb74c1f449f82f5a71250c4c
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Dec  8 04:12:36 2014 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Dec  8 04:12:36 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=b6b75d35

archive.py: Adds kwargs-debug and modifies kwargs-info level to 5

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

diff --git a/layman/overlays/archive.py b/layman/overlays/archive.py
index 5dca6a7..9963f04 100644
--- a/layman/overlays/archive.py
+++ b/layman/overlays/archive.py
@@ -50,7 +50,8 @@ class ArchiveOverlay(OverlaySource):
             connector_output = {
                 'info': self.output.debug,
                 'error': self.output.error,
-                'kwargs-info': {'level': 2},
+                'kwargs-info': {'level': 5},
+                'kwargs-debug': {'level': 2},
                 'kwargs-error': {'level': None},
             }
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-03-26 18:13 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-03-26 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     f581549abe1d807c9d6d84d76978a08c8394ee3b
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 26 18:13:45 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Mar 26 18:13:45 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=f581549a

overlay.py: Adds overlay source protocol filtering

 layman/overlays/overlay.py | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 55ef8a8..59aa74b 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -69,6 +69,29 @@ class Overlay(object):
             self.from_dict(ovl_dict, ignore)
 
 
+    def filter_protocols(self, sources, create_source_func):
+        '''
+        Filters any protocols not specified in self.config['protocol_order']
+        from the overlay's sources.
+        '''
+        _sources = []
+        if not 'protocol_order' in self.config.keys():
+            return [create_source_func(e) for e in sources]
+
+        for e in sources:
+            source = create_source_func(e)
+            for protocol in self.config['protocol_order']:
+                protocol = protocol.lower()
+                #re.search considers "\+" as the literal "+".
+                if protocol == 'git+ssh':
+                    protocol = 'git\+ssh'
+                protocol += '://'
+                if re.search('^' + protocol, source.src):
+                    _sources.append(source)
+
+        return _sources
+
+
     def from_xml(self, xml, ignore):
         """Process an xml overlay definition
         """
@@ -121,7 +144,7 @@ class Overlay(object):
             raise Exception('Overlay from_xml(), "' + self.name + \
                 '" is missing a "source" entry!')
 
-        self.sources = [create_overlay_source(e) for e in _sources]
+        self.sources = self.filter_protocols(_sources, create_overlay_source)
 
         _owner = xml.find('owner')
         if _owner == None:
@@ -231,7 +254,7 @@ class Overlay(object):
             return _class(parent=self, config=self.config,
                 _location=_location, ignore=ignore)
 
-        self.sources = [create_dict_overlay_source(e) for e in _sources]
+        self.sources = self.filter_protocols(_sources, create_dict_overlay_source)
 
         if 'owner_name' in overlay:
             _owner = overlay['owner_name']
@@ -379,6 +402,14 @@ class Overlay(object):
     def add(self, base):
         res = 1
         first_s = True
+
+        if 'protocol_order' in self.config.keys() and not self.sources:
+            msg = 'Overlay.add() error: overlay "%s" does not support any of'\
+                  ' the given\nprotocols %s and cannot be installed.'\
+                  % (self.name, str(self.config['protocol_order']))
+            self.output.error(msg)
+            return 1
+
         for s in self.sources:
             if not first_s:
                 self.output.info("\nTrying next source of listed sources...", 4)


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-03-26 23:08 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-03-26 23:08 UTC (permalink / raw
  To: gentoo-commits

commit:     a263463472cee1763e9e6abb915b015ee1de0cb7
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 26 23:06:25 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Mar 26 23:06:27 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=a2634634

overlay.py: Modifies the implementation of filter_protocols

This modification allows for layman to only filter protocols
when running Overlay.add() and Overlay.update(), preventing
redundant code and checks along the way.

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

 layman/overlays/overlay.py | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 59aa74b..2257373 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -69,17 +69,16 @@ class Overlay(object):
             self.from_dict(ovl_dict, ignore)
 
 
-    def filter_protocols(self, sources, create_source_func):
+    def filter_protocols(self, sources):
         '''
         Filters any protocols not specified in self.config['protocol_order']
         from the overlay's sources.
         '''
         _sources = []
-        if not 'protocol_order' in self.config.keys():
-            return [create_source_func(e) for e in sources]
+        if not self.config['protocol_order']:
+            return sources
 
-        for e in sources:
-            source = create_source_func(e)
+        for source in sources:
             for protocol in self.config['protocol_order']:
                 protocol = protocol.lower()
                 #re.search considers "\+" as the literal "+".
@@ -144,7 +143,7 @@ class Overlay(object):
             raise Exception('Overlay from_xml(), "' + self.name + \
                 '" is missing a "source" entry!')
 
-        self.sources = self.filter_protocols(_sources, create_overlay_source)
+        self.sources = [create_overlay_source(e) for e in _sources]
 
         _owner = xml.find('owner')
         if _owner == None:
@@ -254,7 +253,7 @@ class Overlay(object):
             return _class(parent=self, config=self.config,
                 _location=_location, ignore=ignore)
 
-        self.sources = self.filter_protocols(_sources, create_dict_overlay_source)
+        self.sources = [create_dict_overlay_source(e) for e in _sources]
 
         if 'owner_name' in overlay:
             _owner = overlay['owner_name']
@@ -403,9 +402,10 @@ class Overlay(object):
         res = 1
         first_s = True
 
-        if 'protocol_order' in self.config.keys() and not self.sources:
-            msg = 'Overlay.add() error: overlay "%s" does not support any of'\
-                  ' the given\nprotocols %s and cannot be installed.'\
+        self.sources = filter_protocols(self.sources)
+        if not self.sources:
+            msg = 'Overlay.add() error: overlay "%s" does not support the'\
+                  ' given\nprotocol(s) %s and cannot be installed.'\
                   % (self.name, str(self.config['protocol_order']))
             self.output.error(msg)
             return 1
@@ -430,6 +430,15 @@ class Overlay(object):
         first_src = True
         result = False
 
+        self.sources = filter_protocols(self.sources)
+        available_srcs = filter_protocols(available_srcs)
+        if not self.sources or not available_srcs:
+            msg = 'Overlay.update() error: overlay "%s" does not support the'\
+                  'given protocol(s) %s and cannot be updated.'\
+                  % (self.name, str(self.config['protocol_order'])
+            self.output.error(msg)
+            return 1
+
         if isinstance(available_srcs, str):
             available_srcs = [available_srcs]
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-03-26 23:47 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-03-26 23:47 UTC (permalink / raw
  To: gentoo-commits

commit:     e0f317c1e3443b8b43fe11033897624dbda83483
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 26 23:47:36 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Mar 26 23:47:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=e0f317c1

overlay.py: Closes off interpolation tuple for error message in update()

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

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 2257373..fa728f6 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -435,7 +435,7 @@ class Overlay(object):
         if not self.sources or not available_srcs:
             msg = 'Overlay.update() error: overlay "%s" does not support the'\
                   'given protocol(s) %s and cannot be updated.'\
-                  % (self.name, str(self.config['protocol_order'])
+                  % (self.name, str(self.config['protocol_order']))
             self.output.error(msg)
             return 1
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-10 16:13 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-10 16:13 UTC (permalink / raw
  To: gentoo-commits

commit:     d8b97485f50a4922476787ec1052a55e69ae22cb
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 10 16:14:02 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Jul 10 16:14:08 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=d8b97485

overlay.py: Quick code cleanup

 layman/overlays/overlay.py | 113 ++++++++++++++++++++++++++++-----------------
 1 file changed, 70 insertions(+), 43 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 1ecd509..e4195cf 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -11,14 +11,16 @@
 #             (c) 2005 - 2009 Gunnar Wrobel
 #             (c) 2009        Sebastian Pipping
 #             (c) 2009        Christian Groschupp
+#             (c) 2015        Devan Franchini
 #             Distributed under the terms of the GNU General Public License v2
 #
 # Author(s):
 #             Gunnar Wrobel <wrobel@gentoo.org>
 #             Sebastian Pipping <sebastian@pipping.org>
 #             Christian Groschupp <christian@groschupp.org>
+#             Devan Franchini <twitch153@gentoo.org>
 #
-''' Basic overlay class.'''
+'''Basic overlay class.'''
 
 from __future__ import unicode_literals
 
@@ -92,8 +94,9 @@ class Overlay(object):
 
 
     def from_xml(self, xml, ignore):
-        """Process an xml overlay definition
-        """
+        '''
+        Process an xml overlay definition
+        '''
         def strip_text(node):
             res = node.text
             if res is None:
@@ -101,15 +104,18 @@ class Overlay(object):
             return res.strip()
 
         _name = xml.find('name')
+
         if _name != None:
             self.name = encode(strip_text(_name))
         elif 'name' in xml.attrib:
             self.name = encode(xml.attrib['name'])
         else:
-            raise Exception('Overlay from_xml(), "' + self.name + \
-                'is missing a "name" entry!')
+            msg = 'Overlay from_xml(), "%(name)s" is missing a "name" entry!'\
+                  % {'name': self.name}
+            raise Exception(msg)
 
         _sources = xml.findall('source')
+
         # new xml format
         if _sources != []:
             _sources = [e for e in _sources if 'type' in e.attrib]
@@ -124,6 +130,7 @@ class Overlay(object):
             _branch = ''
             _type = source_elem.attrib['type']
             self.ovl_type = _type
+
             if 'branch' in source_elem.attrib:
                 _branch = source_elem.attrib['branch']
 
@@ -133,23 +140,25 @@ class Overlay(object):
                 _class = self.module_controller.get_class('stub')
 
             _location = encode(strip_text(source_elem))
-
             self.branch = _branch
 
             return _class(parent=self, config=self.config,
                 _location=_location, ignore=ignore)
 
         if not len(_sources):
-            raise Exception('Overlay from_xml(), "' + self.name + \
-                '" is missing a "source" entry!')
+            msg = 'Overlay from_xml(), "%(name)" is missing a "source" entry!'\
+                  % {'name': self.name}
+            raise Exception(msg)
 
         self.sources = [create_overlay_source(e) for e in _sources]
 
         _owner = xml.find('owner')
+
         if _owner == None:
             _email = None
         else:
             _email = _owner.find('email')
+
         if _owner != None and _email != None:
             self.owner_email = encode(strip_text(_email))
             _name = _owner.find('name')
@@ -163,12 +172,12 @@ class Overlay(object):
         else:
             self.owner_email = ''
             self.owner_name = None
+            msg = 'Overlay from_xml(), "%(name)s" is mising an '\
+                  '"owner.email" entry!' % {'name': self.name}
             if not ignore:
-                raise Exception('Overlay  from_xml(), "' + self.name + \
-                    '" is missing an "owner.email" entry!')
+                raise Exception(msg)
             elif ignore == 1:
-                self.output.warn('Overlay "' + self.name + '" is missing a '
-                         '"owner.email" entry!', 4)
+                self.output.warn(msg, 4)
 
         _desc = xml.findall('description')
         if _desc != None:
@@ -178,12 +187,12 @@ class Overlay(object):
                 self.descriptions.append(encode(d))
         else:
             self.descriptions = ['']
+            msg = 'Overlay from_xml(), "%(name)s is missing a '\
+                  '"description" entry!' % {'name': self.name}
             if not ignore:
-                raise Exception('Overlay  from_xml(), "' + self.name + \
-                    '" is missing a description" entry!')
+                raise Exception(msg)
             elif ignore == 1:
-                self.output.warn('Overlay "' + self.name + '" is missing a '
-                         '"description" entry!', 4)
+                self.output.warn(msg, 4)
 
         if 'status' in xml.attrib:
             self.status = encode(xml.attrib['status'])
@@ -202,6 +211,7 @@ class Overlay(object):
 
         h = xml.find('homepage')
         l = xml.find('link')
+
         if h != None:
             self.homepage = encode(strip_text(h))
         elif l != None:
@@ -209,8 +219,7 @@ class Overlay(object):
         else:
             self.homepage = None
 
-        self.feeds = [encode(strip_text(e)) \
-            for e in xml.findall('feed')]
+        self.feeds = [encode(strip_text(e)) for e in xml.findall('feed')]
 
         _irc = xml.find('irc')
         if _irc != None:
@@ -220,21 +229,26 @@ class Overlay(object):
 
 
     def from_dict(self, overlay, ignore):
-        """Process an overlay dictionary definition
-        """
-        self.output.debug("Overlay from_dict(); overlay" + str(overlay), 6)
+        '''
+        Process an overlay dictionary definition
+        '''
+        msg = 'Overlay from_dict(); overlay %(ovl)s' % {'ovl': str(overlay)}
+        self.output.debug(msg, 6)
+
         _name = overlay['name']
         if _name != None:
             self.name = encode(_name)
         else:
-            raise Exception('Overlay from_dict(), "' + self.name +
-                'is missing a "name" entry!')
+            msg = 'Overlay from dict(), "%(name)s" is missing a "name" entry!'\
+                  % {'name': self.name}
+            raise Exception(msg)
 
         _sources = overlay['sources']
 
         if _sources == None:
-            raise Exception('Overlay from_dict(), "' + self.name +
-                '" is missing a "source" entry!')
+            msg = 'Overlay from_dict(), "%(name)s" is missing a "source"'\
+                  'entry!' % {'name': self.name}
+            raise Exception(msg)
 
         def create_dict_overlay_source(source_):
             _src, _type, _sub = source_
@@ -266,12 +280,12 @@ class Overlay(object):
             self.owner_email = encode(_email)
         else:
             self.owner_email = None
+            msg = 'Overlay from_dict(), "%(name)s" is missing an "owner.email"'\
+                  ' entry!' % {'name': self.name}
             if not ignore:
-                raise Exception('Overlay from_dict(), "' + self.name +
-                    '" is missing an "owner.email" entry!')
+                raise Exception(msg)
             elif ignore == 1:
-                self.output.warn('Overlay from_dict(), "' + self.name +
-                    '" is missing an "owner.email" entry!', 4)
+                self.output.warn(msg, 4)
 
         if 'descriptions' in overlay:
             self.descriptions = []
@@ -341,12 +355,16 @@ class Overlay(object):
 
 
     def set_priority(self, priority):
-        '''Set the priority of this overlay.'''
+        '''
+        Set the priority of this overlay.
+        '''
         self.priority = int(priority)
 
 
     def to_xml(self):
-        '''Convert to xml.'''
+        '''
+        Convert to xml.
+        '''
         repo = ET.Element('repo')
         if self.status != None:
             repo.attrib['status'] = self.status
@@ -404,15 +422,17 @@ class Overlay(object):
 
         self.sources = self.filter_protocols(self.sources)
         if not self.sources:
-            msg = 'Overlay.add() error: overlay "%s" does not support the'\
-                  ' given\nprotocol(s) %s and cannot be installed.'\
-                  % (self.name, str(self.config['protocol_filter']))
+            msg = 'Overlay.add() error: overlay "%(name)s" does not support '\
+                  ' the given\nprotocol(s) %(protocol)s and cannot be '\
+                  'installed.'\
+                  % {'name': self.name,
+                     'protocol': str(self.config['protocol_filter'])}
             self.output.error(msg)
             return 1
 
         for s in self.sources:
             if not first_s:
-                self.output.info("\nTrying next source of listed sources...", 4)
+                self.output.info('\nTrying next source of listed sources...', 4)
             try:
                 res = s.add(base)
                 if res == 0:
@@ -433,9 +453,10 @@ class Overlay(object):
         self.sources = self.filter_protocols(self.sources)
         available_srcs = self.filter_protocols(available_srcs)
         if not self.sources or not available_srcs:
-            msg = 'Overlay.update() error: overlay "%s" does not support the'\
-                  'given protocol(s) %s and cannot be updated.'\
-                  % (self.name, str(self.config['protocol_filter']))
+            msg = 'Overlay.update() error: overlay "%(name)s" does not support'\
+                  ' the given protocol(s) %(protocol)s and cannot be updated.'\
+                  % {'name': self.name,
+                     'protocol': str(self.config['protocol_filter'])}
             self.output.error(msg)
             return 1
 
@@ -445,7 +466,7 @@ class Overlay(object):
         if self.sources[0].type in self.config.get_option('support_url_updates'):
             for src in available_srcs:
                 if not first_src:
-                    self.output.info("\nTrying next source of listed sources...", 4)
+                    self.output.info('\nTrying next source of listed sources...', 4)
                 try:
                     res = self.sources[0].update(base, src)
                     if res == 0:
@@ -461,15 +482,19 @@ class Overlay(object):
             # Update the overlay source with the remote
             # source, assuming that it's telling the truth
             # so it can be written to the installed.xml.
-            self.output.debug("overlay.update(); type: %s does not support"\
-                " source URL updating" % self.sources[0].type, 4)
+            msg = 'Overlay.update(); type: "%(src_type)s does not support '\
+                  'source URL updating' % {'src_type': self.sources[0].type}
+            self.output.debug(msg, 4)
+
             self.sources[0].src = available_srcs.pop()
             result = True
         return (self.sources, result)
 
 
     def sync(self, base):
-        self.output.debug("overlay.sync(); name = %s" % self.name, 4)
+        msg = 'Overlay.sync(); name = %(name)s' % {'name': self.name}
+        self.output.debug(msg, 4)
+
         assert len(self.sources) == 1
         return self.sources[0].sync(base)
 
@@ -570,7 +595,9 @@ class Overlay(object):
 
 
     def is_official(self):
-        '''Is the overlay official?'''
+        '''
+        Is the overlay official?
+        '''
         return self.status == 'official'
 
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-13 18:48 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-13 18:48 UTC (permalink / raw
  To: gentoo-commits

commit:     e4162f49357e04722e8db20493e15538e657c3bd
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 13 18:36:51 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Jul 13 18:36:54 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=e4162f49

overlay.py: Adds json support for overlay definitions

Also reorganizes functions alphabetically.

 layman/overlays/overlay.py | 658 +++++++++++++++++++++++++++------------------
 1 file changed, 403 insertions(+), 255 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 423b91e..de0a035 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -56,7 +56,7 @@ WHITESPACE_REGEX = re.compile('\s+')
 class Overlay(object):
     ''' Derive the real implementations from this.'''
 
-    def __init__(self, config, xml=None, ovl_dict=None,
+    def __init__(self, config, json=None, ovl_dict=None, xml=None,
         ignore = 0):
         self.config = config
         self.output = config['output']
@@ -69,6 +69,59 @@ class Overlay(object):
             self.from_xml(xml, ignore)
         elif ovl_dict is not None:
             self.from_dict(ovl_dict, ignore)
+        elif json is not None:
+            self.from_json(ovl_dict, ignore)
+
+
+    def __eq__(self, other):
+        for i in ('descriptions', 'homepage', 'name', 'owner_email',
+                'owner_name', 'priority', 'status'):
+            if getattr(self, i) != getattr(other, i):
+                return False
+        for i in self.sources + other.sources:
+            if not i in self.sources:
+                return False
+            if not i in other.sources:
+                return False
+        return True
+
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+
+    def add(self, base):
+        res = 1
+        first_s = True
+
+        self.sources = self.filter_protocols(self.sources)
+        if not self.sources:
+            msg = 'Overlay.add() error: overlay "%(name)s" does not support '\
+                  ' the given\nprotocol(s) %(protocol)s and cannot be '\
+                  'installed.'\
+                  % {'name': self.name,
+                     'protocol': str(self.config['protocol_filter'])}
+            self.output.error(msg)
+            return 1
+
+        for s in self.sources:
+            if not first_s:
+                self.output.info('\nTrying next source of listed sources...', 4)
+            try:
+                res = s.add(base)
+                if res == 0:
+                    # Worked, throw other sources away
+                    self.sources = [s]
+                    break
+            except Exception as error:
+                self.output.warn(str(error), 4)
+            first_s = False
+        return res
+
+
+    def delete(self, base):
+        assert len(self.sources) == 1
+        return self.sources[0].delete(base)
 
 
     def filter_protocols(self, sources):
@@ -93,6 +146,226 @@ class Overlay(object):
         return _sources
 
 
+    def from_dict(self, overlay, ignore):
+        '''
+        Process an overlay dictionary definition
+        '''
+        msg = 'Overlay from_dict(); overlay %(ovl)s' % {'ovl': str(overlay)}
+        self.output.debug(msg, 6)
+
+        _name = overlay['name']
+        if _name != None:
+            self.name = encode(_name)
+        else:
+            msg = 'Overlay from dict(), "%(name)s" is missing a "name" entry!'\
+                  % {'name': self.name}
+            raise Exception(msg)
+
+        _sources = overlay['source']
+
+        if _sources == None:
+            msg = 'Overlay from_dict(), "%(name)s" is missing a "source"'\
+                  'entry!' % {'name': self.name}
+            raise Exception(msg)
+
+        def create_dict_overlay_source(source_):
+            _src, _type, _sub = source_
+            self.ovl_type = _type
+            try:
+                _class = self.module_controller.get_class(_type)
+            except InvalidModuleName:
+                _class = self.module_controller.get_class('stub')
+
+            _location = encode(_src)
+            if _sub:
+                self.branch = encode(_sub)
+            else:
+                self.branch = None
+
+            return _class(parent=self, config=self.config,
+                _location=_location, ignore=ignore)
+
+        self.sources = [create_dict_overlay_source(e) for e in _sources]
+
+        if 'owner_name' in overlay:
+            _owner = overlay['owner_name']
+            self.owner_name = encode(_owner)
+        else:
+            self.owner_name = None
+
+        if 'owner_email' in overlay:
+            _email = overlay['owner_email']
+            self.owner_email = encode(_email)
+        else:
+            self.owner_email = None
+            msg = 'Overlay from_dict(), "%(name)s" is missing an "owner.email"'\
+                  ' entry!' % {'name': self.name}
+            if not ignore:
+                raise Exception(msg)
+            elif ignore == 1:
+                self.output.warn(msg, 4)
+
+        if 'description' in overlay:
+            self.descriptions = []
+            _descs = overlay['description']
+            for d in _descs:
+                d = WHITESPACE_REGEX.sub(' ', d)
+                self.descriptions.append(encode(d))
+        else:
+            self.descriptions = ['']
+            if not ignore:
+                raise Exception('Overlay from_dict(), "' + self.name +
+                    '" is missing a "description" entry!')
+            elif ignore == 1:
+                self.output.warn('Overlay from_dict(), "' + self.name +
+                    '" is missing a "description" entry!', 4)
+
+        if 'status' in overlay:
+            self.status = encode(overlay['status'])
+        else:
+            self.status = None
+
+        self.quality = 'experimental'
+        if 'quality' in overlay:
+            if overlay['quality'] in set(QUALITY_LEVELS):
+                self.quality = encode(overlay['quality'])
+
+        if 'priority' in overlay:
+            self.priority = int(overlay['priority'])
+        else:
+            self.priority = 50
+
+        if 'homepage' in overlay:
+            self.homepage = encode(overlay['homepage'])
+        else:
+            self.homepage = None
+
+        if 'feed' in overlay:
+            self.feeds = [encode(e) \
+                for e in overlay['feed']]
+        else:
+            self.feeds = None
+
+        if 'irc' in overlay:
+            self.irc = encode(overlay['irc'])
+        else:
+            self.irc = None
+
+        # end of from_dict
+
+
+    def from_json(self, json, ignore):
+        '''
+        Process a json overlay definition
+        '''
+        msg = 'Overlay from_json(); overlay %(ovl)s' % {'ovl': str(overlay)}
+        self.output.debug(msg, 6)
+
+        _name = overlay['name']
+        if _name != None:
+            self.name = encode(_name)
+        else:
+            msg = 'Overlay from_json(), "name" entry missing from json!'
+            raise Exception(msg)
+
+        _sources = overlay['source']
+
+        if _sources == None:
+            msg = 'Overlay from_json(), "%(name)s" is missing a "source"'\
+                  'entry!' % {'name': self.name}
+            raise Exception(msg)
+
+        def create_json_overlay_source(source_):
+            _src = source_['#text']
+            _type = source_['@type']
+            if '@branch' in source_:
+                _sub = source_['@branch']
+            else:
+                _sub = ''
+
+            self.ovl_type = _type
+
+            try:
+                _class = self.module_controller.get_class(_type)
+            except InvalidModuleName:
+                _class = self.module_controller.get_class('stub')
+
+            _location = encode(_src)
+            if _sub:
+                self.branch = encode(_sub)
+            else:
+                self.branch = None
+
+            return _class(parent=self, config=self.config,
+                _location=_location, ignore=ignore)
+
+        self.sources = [create_json_overlay_source(e) for e in _sources]
+
+        if 'name' in overlay['owner']:
+            self.owner_name = encode(overlay['owner']['name'])
+        else:
+            self.owner_name = None
+
+        if 'email' in overlay['owner']:
+            self.owner_email = encode(overlay['owner']['email'])
+        else:
+            self.owner_email = None
+            msg = 'Overlay from_json(), "%(name)s" is missing an "owner.email"'\
+                  'entry!' % {'name': self.name}
+            if not ignore:
+                raise Exception(msg)
+            else ignore == 1:
+                self.output.warn(msg, 4)
+
+         if 'description' in overlay:
+            self.descriptions = []
+            _descs = overlay['description']
+            for d in _descs:
+                d = WHITESPACE_REGEX.sub(' ', d['#text'])
+                self.descriptions.append(encode(d))
+        else:
+            self.descriptions = ['']
+            if not ignore:
+                raise Exception('Overlay from_json(), "' + self.name +
+                    '" is missing a "description" entry!')
+            elif ignore == 1:
+                self.output.warn('Overlay from_json(), "' + self.name +
+                    '" is missing a "description" entry!', 4)
+
+        if '@status' in overlay:
+            self.status = encode(overlay['@status'])
+        else:
+            self.status = None
+
+        self.quality = 'experimental'
+        if '@quality' in overlay:
+            if overlay['@quality'] in set(QUALITY_LEVELS):
+                self.quality = encode(overlay['@quality'])
+
+        if '@priority' in overlay:
+            self.priority = int(overlay['@priority'])
+        else:
+            self.priority = 50
+
+        if 'homepage' in overlay:
+            self.homepage = encode(overlay['homepage'])
+        else:
+            self.homepage = None
+
+        if 'feed' in overlay:
+            self.feeds = [encode(e) \
+                for e in overlay['feed']]
+        else:
+            self.feeds = None
+
+        if 'irc' in overlay:
+            self.irc = encode(overlay['irc'])
+        else:
+            self.irc = None
+
+        # end of from_json()
+
+
     def from_xml(self, xml, ignore):
         '''
         Process an xml overlay definition
@@ -228,136 +501,164 @@ class Overlay(object):
             self.irc = None
 
 
-    def from_dict(self, overlay, ignore):
+    def get_infostr(self):
         '''
-        Process an overlay dictionary definition
+        Gives more detailed string of overlay information.
+
+        @rtype str: encoded overlay information.
         '''
-        msg = 'Overlay from_dict(); overlay %(ovl)s' % {'ovl': str(overlay)}
-        self.output.debug(msg, 6)
 
-        _name = overlay['name']
-        if _name != None:
-            self.name = encode(_name)
-        else:
-            msg = 'Overlay from dict(), "%(name)s" is missing a "name" entry!'\
-                  % {'name': self.name}
-            raise Exception(msg)
+        result = ''
 
-        _sources = overlay['source']
+        result += self.name + '\n' + (len(self.name) * '~')
 
-        if _sources == None:
-            msg = 'Overlay from_dict(), "%(name)s" is missing a "source"'\
-                  'entry!' % {'name': self.name}
-            raise Exception(msg)
+        if len(self.sources) == 1:
+            result += '\nSource  : ' + self.sources[0].src
+        else:
+            result += '\nSources:'
+            for i, v in enumerate(self.sources):
+                result += '\n  %d. %s' % (i + 1, v.src)
+            result += '\n'
 
-        def create_dict_overlay_source(source_):
-            _src, _type, _sub = source_
-            self.ovl_type = _type
-            try:
-                _class = self.module_controller.get_class(_type)
-            except InvalidModuleName:
-                _class = self.module_controller.get_class('stub')
+        if self.owner_name != None:
+            result += '\nContact : %s <%s>' \
+                % (self.owner_name, self.owner_email)
+        else:
+            result += '\nContact : ' + self.owner_email
+        if len(self.sources) == 1:
+            result += '\nType    : ' + self.sources[0].type
+        else:
+            result += '\nType    : ' + '/'.join(
+                sorted(set(e.type for e in self.sources)))
+        result += '; Priority: ' + str(self.priority) + '\n'
+        result += 'Quality : ' + self.quality + '\n'
 
-            _location = encode(_src)
-            if _sub:
-                self.branch = encode(_sub)
-            else:
-                self.branch = None
 
-            return _class(parent=self, config=self.config,
-                _location=_location, ignore=ignore)
+        for description in self.descriptions:
+            description = re.compile(' +').sub(' ', description)
+            description = re.compile('\n ').sub('\n', description)
+            result += '\nDescription:'
+            result += '\n  '.join(('\n' + description).split('\n'))
+            result += '\n'
 
-        self.sources = [create_dict_overlay_source(e) for e in _sources]
+        if self.homepage != None:
+            link = self.homepage
+            link = re.compile(' +').sub(' ', link)
+            link = re.compile('\n ').sub('\n', link)
+            result += '\nLink:'
+            result += '\n  '.join(('\n' + link).split('\n'))
+            result += '\n'
 
-        if 'owner_name' in overlay:
-            _owner = overlay['owner_name']
-            self.owner_name = encode(_owner)
-        else:
-            self.owner_name = None
+        if self.irc != None:
+            result += '\nIRC : ' + self.irc + '\n'
 
-        if 'owner_email' in overlay:
-            _email = overlay['owner_email']
-            self.owner_email = encode(_email)
-        else:
-            self.owner_email = None
-            msg = 'Overlay from_dict(), "%(name)s" is missing an "owner.email"'\
-                  ' entry!' % {'name': self.name}
-            if not ignore:
-                raise Exception(msg)
-            elif ignore == 1:
-                self.output.warn(msg, 4)
+        if len(self.feeds):
+            result += '\n%s:' % ((len(self.feeds) == 1) and "Feed" or "Feeds")
+            for i in self.feeds:
+                result += '\n  %s' % i
+            result += '\n'
 
-        if 'description' in overlay:
-            self.descriptions = []
-            _descs = overlay['description']
-            for d in _descs:
-                d = WHITESPACE_REGEX.sub(' ', d)
-                self.descriptions.append(encode(d))
-        else:
-            self.descriptions = ['']
-            if not ignore:
-                raise Exception('Overlay from_dict(), "' + self.name +
-                    '" is missing a "description" entry!')
-            elif ignore == 1:
-                self.output.warn('Overlay from_dict(), "' + self.name +
-                    '" is missing a "description" entry!', 4)
+        return encoder(result, self._encoding_)
 
-        if 'status' in overlay:
-            self.status = encode(overlay['status'])
-        else:
-            self.status = None
 
-        self.quality = 'experimental'
-        if 'quality' in overlay:
-            if overlay['quality'] in set(QUALITY_LEVELS):
-                self.quality = encode(overlay['quality'])
+    def is_supported(self):
+        return any(e.is_supported() for e in self.sources)
 
-        if 'priority' in overlay:
-            self.priority = int(overlay['priority'])
-        else:
-            self.priority = 50
 
-        if 'homepage' in overlay:
-            self.homepage = encode(overlay['homepage'])
-        else:
-            self.homepage = None
+    def set_priority(self, priority):
+        '''
+        Set the priority of this overlay.
+        '''
+        self.priority = int(priority)
 
-        if 'feed' in overlay:
-            self.feeds = [encode(e) \
-                for e in overlay['feed']]
+
+    def short_list(self, width = 0):
+        '''
+        Return a shortened list of overlay information.
+
+        @params width: int specifying terminal width.
+        @rtype str: string of overlay information.
+        '''
+        if len(self.name) > 25:
+            name = self.name + "   ###\n"
+            name += pad(" ", 25)
         else:
-            self.feeds = None
+            name   = pad(self.name, 25)
 
-        if 'irc' in overlay:
-            self.irc = encode(overlay['irc'])
+        if len(set(e.type for e in self.sources)) == 1:
+            _type = self.sources[0].type
         else:
-            self.irc = None
+            _type = '%s/..' % self.sources[0].type
 
-        # end of from_dict
+        mtype  = ' [' + pad(_type, 10) + ']'
+        if not width:
+            width = terminal_width()-1
+        srclen = width - 43
+        source = ', '.join(self.source_uris())
+        if len(source) > srclen:
+            source = source.replace("overlays.gentoo.org", "o.g.o")
+        source = ' (' + pad(source, srclen) + ')'
 
+        return encoder(name + mtype + source, self._encoding_)
 
-    def __eq__(self, other):
-        for i in ('descriptions', 'homepage', 'name', 'owner_email',
-                'owner_name', 'priority', 'status'):
-            if getattr(self, i) != getattr(other, i):
-                return False
-        for i in self.sources + other.sources:
-            if not i in self.sources:
-                return False
-            if not i in other.sources:
-                return False
-        return True
 
+    def source_types(self):
+        for i in self.sources:
+            yield i.type    def is_official(self):
+        '''
+        Is the overlay official?
+        '''
+        return self.status == 'official'
 
-    def __ne__(self, other):
-        return not self.__eq__(other)
 
+    def source_uris(self):
+        for i in self.sources:
+            yield i.src
 
-    def set_priority(self, priority):
+
+    def sync(self, base):
+        msg = 'Overlay.sync(); name = %(name)s' % {'name': self.name}
+        self.output.debug(msg, 4)
+
+        assert len(self.sources) == 1
+        return self.sources[0].sync(base)
+
+
+    def to_json(self):
         '''
-        Set the priority of this overlay.
+        Convert to json.
         '''
-        self.priority = int(priority)
+        repo = {}
+
+        repo['@priority'] = str(self.priority)
+        repo['@quality'] = self.quality
+        if self.status != None:
+            repo['@status'] = self.status
+        repo['name'] = self.name
+        repo['description'] = []
+        for i in self.descriptions:
+            repo['description'].append(i)
+        if self.homepage != None:
+            repo['homepage'] = self.homepage
+        if self.irc != None:
+            repo['irc'] = self.irc
+        repo['owner'] = {}
+        repo['owner']['email'] = self.owner_email
+        if self.owner_name != None:
+            repo['owner']['name'] = self.owner_name
+        repo['source'] = []
+        for i in self.sources:
+            source = {'@type': i.__class__.type_key}
+            if i.branch:
+                source['@branch'] = i.branch
+            source['#text'] = i.src
+            repo['source'].append(source)
+        if self.feeds != None:
+            repo['feed'] = []
+            for feed in self.feeds:
+                repo['feed'].append(feed)
+
+        return repo
 
 
     def to_xml(self):
@@ -415,35 +716,6 @@ class Overlay(object):
         return repo
 
 
-    def add(self, base):
-        res = 1
-        first_s = True
-
-        self.sources = self.filter_protocols(self.sources)
-        if not self.sources:
-            msg = 'Overlay.add() error: overlay "%(name)s" does not support '\
-                  ' the given\nprotocol(s) %(protocol)s and cannot be '\
-                  'installed.'\
-                  % {'name': self.name,
-                     'protocol': str(self.config['protocol_filter'])}
-            self.output.error(msg)
-            return 1
-
-        for s in self.sources:
-            if not first_s:
-                self.output.info('\nTrying next source of listed sources...', 4)
-            try:
-                res = s.add(base)
-                if res == 0:
-                    # Worked, throw other sources away
-                    self.sources = [s]
-                    break
-            except Exception as error:
-                self.output.warn(str(error), 4)
-            first_s = False
-        return res
-
-
     def update(self, base, available_srcs):
         res = 1
         first_src = True
@@ -488,127 +760,3 @@ class Overlay(object):
             self.sources[0].src = available_srcs.pop()
             result = True
         return (self.sources, result)
-
-
-    def sync(self, base):
-        msg = 'Overlay.sync(); name = %(name)s' % {'name': self.name}
-        self.output.debug(msg, 4)
-
-        assert len(self.sources) == 1
-        return self.sources[0].sync(base)
-
-
-    def delete(self, base):
-        assert len(self.sources) == 1
-        return self.sources[0].delete(base)
-
-
-    def get_infostr(self):
-        '''
-        Gives more detailed string of overlay information.
-
-        @rtype str: encoded overlay information.
-        '''
-
-        result = ''
-
-        result += self.name + '\n' + (len(self.name) * '~')
-
-        if len(self.sources) == 1:
-            result += '\nSource  : ' + self.sources[0].src
-        else:
-            result += '\nSources:'
-            for i, v in enumerate(self.sources):
-                result += '\n  %d. %s' % (i + 1, v.src)
-            result += '\n'
-
-        if self.owner_name != None:
-            result += '\nContact : %s <%s>' \
-                % (self.owner_name, self.owner_email)
-        else:
-            result += '\nContact : ' + self.owner_email
-        if len(self.sources) == 1:
-            result += '\nType    : ' + self.sources[0].type
-        else:
-            result += '\nType    : ' + '/'.join(
-                sorted(set(e.type for e in self.sources)))
-        result += '; Priority: ' + str(self.priority) + '\n'
-        result += 'Quality : ' + self.quality + '\n'
-
-
-        for description in self.descriptions:
-            description = re.compile(' +').sub(' ', description)
-            description = re.compile('\n ').sub('\n', description)
-            result += '\nDescription:'
-            result += '\n  '.join(('\n' + description).split('\n'))
-            result += '\n'
-
-        if self.homepage != None:
-            link = self.homepage
-            link = re.compile(' +').sub(' ', link)
-            link = re.compile('\n ').sub('\n', link)
-            result += '\nLink:'
-            result += '\n  '.join(('\n' + link).split('\n'))
-            result += '\n'
-
-        if self.irc != None:
-            result += '\nIRC : ' + self.irc + '\n'
-
-        if len(self.feeds):
-            result += '\n%s:' % ((len(self.feeds) == 1) and "Feed" or "Feeds")
-            for i in self.feeds:
-                result += '\n  %s' % i
-            result += '\n'
-
-        return encoder(result, self._encoding_)
-
-
-    def short_list(self, width = 0):
-        '''
-        Return a shortened list of overlay information.
-
-        @params width: int specifying terminal width.
-        @rtype str: string of overlay information.
-        '''
-        if len(self.name) > 25:
-            name = self.name + "   ###\n"
-            name += pad(" ", 25)
-        else:
-            name   = pad(self.name, 25)
-
-        if len(set(e.type for e in self.sources)) == 1:
-            _type = self.sources[0].type
-        else:
-            _type = '%s/..' % self.sources[0].type
-
-        mtype  = ' [' + pad(_type, 10) + ']'
-        if not width:
-            width = terminal_width()-1
-        srclen = width - 43
-        source = ', '.join(self.source_uris())
-        if len(source) > srclen:
-            source = source.replace("overlays.gentoo.org", "o.g.o")
-        source = ' (' + pad(source, srclen) + ')'
-
-        return encoder(name + mtype + source, self._encoding_)
-
-
-    def is_official(self):
-        '''
-        Is the overlay official?
-        '''
-        return self.status == 'official'
-
-
-    def is_supported(self):
-        return any(e.is_supported() for e in self.sources)
-
-
-    def source_uris(self):
-        for i in self.sources:
-            yield i.src
-
-
-    def source_types(self):
-        for i in self.sources:
-            yield i.type


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-13 18:52 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-13 18:52 UTC (permalink / raw
  To: gentoo-commits

commit:     9128580881ba70dbd1bd08e4cdcd8731a46699cd
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 13 18:52:15 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Jul 13 18:52:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=91285808

overlay.py: Modifies error message for missing "name" entry

If the Overlay object has no name then trying to use the name would
result in erroneous or illogical reporting.

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

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index de0a035..024989c 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -157,8 +157,7 @@ class Overlay(object):
         if _name != None:
             self.name = encode(_name)
         else:
-            msg = 'Overlay from dict(), "%(name)s" is missing a "name" entry!'\
-                  % {'name': self.name}
+            msg = 'Overlay from_dict(), "name" entry missing from dictionary!'
             raise Exception(msg)
 
         _sources = overlay['source']
@@ -383,8 +382,7 @@ class Overlay(object):
         elif 'name' in xml.attrib:
             self.name = encode(xml.attrib['name'])
         else:
-            msg = 'Overlay from_xml(), "%(name)s" is missing a "name" entry!'\
-                  % {'name': self.name}
+            msg = 'Overlay from_xml(), "name" entry missing from xml!'
             raise Exception(msg)
 
         _sources = xml.findall('source')


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-13 18:59 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-13 18:59 UTC (permalink / raw
  To: gentoo-commits

commit:     73aa4d1bc690dbef69c0c00dfc629209a3a8540e
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 13 19:00:41 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Jul 13 19:00:41 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=73aa4d1b

overlay.py: Corrects else on line 316

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

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 024989c..cf99499 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -313,7 +313,7 @@ class Overlay(object):
                   'entry!' % {'name': self.name}
             if not ignore:
                 raise Exception(msg)
-            else ignore == 1:
+            elif ignore == 1:
                 self.output.warn(msg, 4)
 
          if 'description' in overlay:


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-13 19:04 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-13 19:04 UTC (permalink / raw
  To: gentoo-commits

commit:     8279886d04bb1469753144c1d204fd1ae20f528f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 13 19:05:30 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Jul 13 19:05:30 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=8279886d

overlay.py: Fixes any other mistakes made in haste

 layman/overlays/overlay.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index cf99499..82e2f9f 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -316,7 +316,7 @@ class Overlay(object):
             elif ignore == 1:
                 self.output.warn(msg, 4)
 
-         if 'description' in overlay:
+        if 'description' in overlay:
             self.descriptions = []
             _descs = overlay['description']
             for d in _descs:
@@ -602,7 +602,10 @@ class Overlay(object):
 
     def source_types(self):
         for i in self.sources:
-            yield i.type    def is_official(self):
+            yield i.type
+
+
+    def is_official(self):
         '''
         Is the overlay official?
         '''


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-13 23:05 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-13 23:05 UTC (permalink / raw
  To: gentoo-commits

commit:     9a56f1ac6a40446ea8cc210a25621e9ad1ccbe80
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 13 22:46:34 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Jul 13 22:46:34 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=9a56f1ac

overlay.py: Renames overlay variable to json to match parameter

 layman/overlays/overlay.py | 56 +++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 82e2f9f..6e289b6 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -70,7 +70,7 @@ class Overlay(object):
         elif ovl_dict is not None:
             self.from_dict(ovl_dict, ignore)
         elif json is not None:
-            self.from_json(ovl_dict, ignore)
+            self.from_json(json, ignore)
 
 
     def __eq__(self, other):
@@ -257,17 +257,17 @@ class Overlay(object):
         '''
         Process a json overlay definition
         '''
-        msg = 'Overlay from_json(); overlay %(ovl)s' % {'ovl': str(overlay)}
+        msg = 'Overlay from_json(); overlay %(ovl)s' % {'ovl': str(json)}
         self.output.debug(msg, 6)
 
-        _name = overlay['name']
+        _name = json['name']
         if _name != None:
             self.name = encode(_name)
         else:
             msg = 'Overlay from_json(), "name" entry missing from json!'
             raise Exception(msg)
 
-        _sources = overlay['source']
+        _sources = json['source']
 
         if _sources == None:
             msg = 'Overlay from_json(), "%(name)s" is missing a "source"'\
@@ -300,13 +300,13 @@ class Overlay(object):
 
         self.sources = [create_json_overlay_source(e) for e in _sources]
 
-        if 'name' in overlay['owner']:
-            self.owner_name = encode(overlay['owner']['name'])
+        if 'name' in json['owner']:
+            self.owner_name = encode(json['owner']['name'])
         else:
             self.owner_name = None
 
-        if 'email' in overlay['owner']:
-            self.owner_email = encode(overlay['owner']['email'])
+        if 'email' in json['owner']:
+            self.owner_email = encode(json['owner']['email'])
         else:
             self.owner_email = None
             msg = 'Overlay from_json(), "%(name)s" is missing an "owner.email"'\
@@ -316,49 +316,49 @@ class Overlay(object):
             elif ignore == 1:
                 self.output.warn(msg, 4)
 
-        if 'description' in overlay:
+        if 'description' in json:
             self.descriptions = []
-            _descs = overlay['description']
+            _descs = json['description']
             for d in _descs:
-                d = WHITESPACE_REGEX.sub(' ', d['#text'])
+                d = WHITESPACE_REGEX.sub(' ', d)
                 self.descriptions.append(encode(d))
         else:
             self.descriptions = ['']
+            msg = 'Overlay from_json() "%(name)s" is missing description'\
+                  'entry!' % {'name': self.name}
             if not ignore:
-                raise Exception('Overlay from_json(), "' + self.name +
-                    '" is missing a "description" entry!')
+                raise Exception(msg)
             elif ignore == 1:
-                self.output.warn('Overlay from_json(), "' + self.name +
-                    '" is missing a "description" entry!', 4)
+                self.output.warn(msg, 4)
 
-        if '@status' in overlay:
-            self.status = encode(overlay['@status'])
+        if '@status' in json:
+            self.status = encode(json['@status'])
         else:
             self.status = None
 
         self.quality = 'experimental'
-        if '@quality' in overlay:
-            if overlay['@quality'] in set(QUALITY_LEVELS):
-                self.quality = encode(overlay['@quality'])
+        if '@quality' in json:
+            if json['@quality'] in set(QUALITY_LEVELS):
+                self.quality = encode(json['@quality'])
 
-        if '@priority' in overlay:
-            self.priority = int(overlay['@priority'])
+        if '@priority' in json:
+            self.priority = int(json['@priority'])
         else:
             self.priority = 50
 
-        if 'homepage' in overlay:
-            self.homepage = encode(overlay['homepage'])
+        if 'homepage' in json:
+            self.homepage = encode(json['homepage'])
         else:
             self.homepage = None
 
-        if 'feed' in overlay:
+        if 'feed' in json:
             self.feeds = [encode(e) \
-                for e in overlay['feed']]
+                for e in json['feed']]
         else:
             self.feeds = None
 
-        if 'irc' in overlay:
-            self.irc = encode(overlay['irc'])
+        if 'irc' in json:
+            self.irc = encode(json['irc'])
         else:
             self.irc = None
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-14 15:15 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-14 15:15 UTC (permalink / raw
  To: gentoo-commits

commit:     cf8329cb7218173bba6cc57ed8f43e54e8ec9775
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 14 15:15:54 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Jul 14 15:15:54 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=cf8329cb

overlay.py: Adds better error handling for missing "source" entries

 layman/overlays/overlay.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 6e289b6..c6a0cee 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -160,10 +160,13 @@ class Overlay(object):
             msg = 'Overlay from_dict(), "name" entry missing from dictionary!'
             raise Exception(msg)
 
-        _sources = overlay['source']
+        if 'source' in overlay:
+            _sources = overlay['source']
+        else:
+            _sources = None
 
         if _sources == None:
-            msg = 'Overlay from_dict(), "%(name)s" is missing a "source"'\
+            msg = 'Overlay from_dict(), "%(name)s" is missing a "source" '\
                   'entry!' % {'name': self.name}
             raise Exception(msg)
 
@@ -267,10 +270,13 @@ class Overlay(object):
             msg = 'Overlay from_json(), "name" entry missing from json!'
             raise Exception(msg)
 
-        _sources = json['source']
+        if 'source' in json:
+            _sources = json['source']
+        else:
+            _sources = None
 
         if _sources == None:
-            msg = 'Overlay from_json(), "%(name)s" is missing a "source"'\
+            msg = 'Overlay from_json(), "%(name)s" is missing a "source" '\
                   'entry!' % {'name': self.name}
             raise Exception(msg)
 


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-07-21 16:39 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-07-21 16:39 UTC (permalink / raw
  To: gentoo-commits

commit:     8133bd98d60e3e1ed38fa75662ae9b070a156336
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 21 16:37:53 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Tue Jul 21 16:37:53 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=8133bd98

overlay.py: Adds optional license attribute to overlay object

 layman/overlays/overlay.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index c6a0cee..8f31a76 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -237,6 +237,11 @@ class Overlay(object):
         else:
             self.priority = 50
 
+        if 'license' in overlay:
+            self.license = encode(overlay['license'])
+        else:
+            self.license = None
+
         if 'homepage' in overlay:
             self.homepage = encode(overlay['homepage'])
         else:
@@ -352,6 +357,11 @@ class Overlay(object):
         else:
             self.priority = 50
 
+        if '@license' in json:
+            self.license = encode(json['@license'])
+        else:
+            self.license = None
+
         if 'homepage' in json:
             self.homepage = encode(json['homepage'])
         else:
@@ -486,6 +496,11 @@ class Overlay(object):
         else:
             self.priority = 50
 
+        if 'license' in xml.attrib:
+            self.license = encode(xml.attrib['license'])
+        else:
+            self.license = None
+
         h = xml.find('homepage')
         l = xml.find('link')
 
@@ -641,6 +656,8 @@ class Overlay(object):
         repo['@quality'] = self.quality
         if self.status != None:
             repo['@status'] = self.status
+        if self.license != None:
+            repo['@license'] = self.license
         repo['name'] = self.name
         repo['description'] = []
         for i in self.descriptions:
@@ -677,6 +694,8 @@ class Overlay(object):
             repo.attrib['status'] = self.status
         repo.attrib['quality'] = self.quality
         repo.attrib['priority'] = str(self.priority)
+        if self.license != None:
+            repo.attrib['license'] = self.license
         name = ET.Element('name')
         name.text = self.name
         repo.append(name)


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-08-04  0:23 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-08-04  0:23 UTC (permalink / raw
  To: gentoo-commits

commit:     16752532c5f7e3dd74745f4ca093278f8c71a90f
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon Aug  3 20:26:41 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon Aug  3 20:26:41 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=16752532

overlay.py: Reorganizes imports and cleans up init params

 layman/overlays/overlay.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8f31a76..31fe400 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -32,9 +32,12 @@ __version__ = "0.2"
 #
 #-------------------------------------------------------------------------------
 
-import sys, re, os, os.path
 import codecs
 import locale
+import os
+import os.path
+import re
+import sys
 import xml.etree.ElementTree as ET # Python 2.5
 
 from  layman.compatibility import encode
@@ -56,8 +59,7 @@ WHITESPACE_REGEX = re.compile('\s+')
 class Overlay(object):
     ''' Derive the real implementations from this.'''
 
-    def __init__(self, config, json=None, ovl_dict=None, xml=None,
-        ignore = 0):
+    def __init__(self, config, json=None, ovl_dict=None, xml=None, ignore=0):
         self.config = config
         self.output = config['output']
         self.module_controller = Modules(path=MOD_PATH,


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-08-28  0:41 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-08-28  0:41 UTC (permalink / raw
  To: gentoo-commits

commit:     bd5d65f3a1c6030fa63f6f3972a67f688d015cbc
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 27 17:36:22 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Thu Aug 27 17:36:22 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=bd5d65f3

overlay.py: Improves to_json() setting of descriptions

 layman/overlays/overlay.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 31fe400..defa4e3 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -661,9 +661,7 @@ class Overlay(object):
         if self.license != None:
             repo['@license'] = self.license
         repo['name'] = self.name
-        repo['description'] = []
-        for i in self.descriptions:
-            repo['description'].append(i)
+        repo['description'] = [i for i in self.descriptions]
         if self.homepage != None:
             repo['homepage'] = self.homepage
         if self.irc != None:


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-08-28  3:43 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-08-28  3:43 UTC (permalink / raw
  To: gentoo-commits

commit:     8363c11894f9fc724f1c5d46d115c3d5919cbc37
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 28 02:54:22 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 28 02:54:26 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=8363c118

overlay.py: Modifies __eq__ attribute requirements

The previous method still made use of owner_name and owner_email to see
if the two were equal while it should've been checking for the "owners"
overlay attribute.

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

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 11536d4..8052d4c 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -76,8 +76,8 @@ class Overlay(object):
 
 
     def __eq__(self, other):
-        for i in ('descriptions', 'homepage', 'name', 'owner_email',
-                'owner_name', 'priority', 'status'):
+        for i in ('descriptions', 'homepage', 'name', 'owners', 'priority',
+                  'status'):
             if getattr(self, i) != getattr(other, i):
                 return False
         for i in self.sources + other.sources:


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

* [gentoo-commits] proj/layman:master commit in: layman/overlays/
@ 2015-08-28  3:50 Devan Franchini
  0 siblings, 0 replies; 51+ messages in thread
From: Devan Franchini @ 2015-08-28  3:50 UTC (permalink / raw
  To: gentoo-commits

commit:     4c8a81001eb813a4ec25584cacdd97c87f176c84
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 28 03:47:35 2015 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Fri Aug 28 03:47:38 2015 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=4c8a8100

overlay.py: Fixes method of assigning owner info if contact attrib is found

Prior to this commit the overlay would not set the owner info if the
contact attribute was found, breaking backwards compatibility. To allow
for this backwards compatibility while maintaining multiple owner
support layman will be defaulting to the "contact" attribute if it is
present in any XML overlays.

 layman/overlays/overlay.py | 49 ++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
index 8052d4c..9cbeb99 100755
--- a/layman/overlays/overlay.py
+++ b/layman/overlays/overlay.py
@@ -454,32 +454,35 @@ class Overlay(object):
         _owners = xml.findall('owner')
         self.owners = []
 
-        for _owner in _owners:
-            owner = {}
+        # For backwards compatibility with older Overlay XML formats
+        # default to this.
+        if 'contact' in xml.attrib:
+            owner = {'email': encode(xml.attrib['contact']),
+                     'name': None}
+            self.owners.append(owner)
+        else:
+            for _owner in _owners:
+                owner = {}
 
-            _email = _owner.find('email')
-            _name = _owner.find('name')
+                _email = _owner.find('email')
+                _name = _owner.find('name')
 
-            if _name != None:
-                owner['name'] = encode(strip_text(_name))
-            else:
-                owner['name'] = None
-            if _email != None:
-                owner['email'] = encode(strip_text(_email))
-            else:
-                owner['email'] = None
-                msg = 'Overlay from_xml(), "%(name)s" is missing an '\
-                      '"owner.email" entry!' % {'name': self.name}
-                if not ignore:
-                    raise Exception(msg)
-                elif ignore == 1:
-                    self.output.warn(msg, 4)
+                if _name != None:
+                    owner['name'] = encode(strip_text(_name))
+                else:
+                    owner['name'] = None
+                if _email != None:
+                    owner['email'] = encode(strip_text(_email))
+                else:
+                    owner['email'] = None
+                    msg = 'Overlay from_xml(), "%(name)s" is missing an '\
+                          '"owner.email" entry!' % {'name': self.name}
+                    if not ignore:
+                        raise Exception(msg)
+                    elif ignore == 1:
+                        self.output.warn(msg, 4)
 
-            # For backwards compatibility with older Overlay XML formats.
-            if not _email and not _name and 'contact' in xml.attrib:
-                owner['email'] = encode(xml.attrib['contact'])
-                owner['name'] = None
-            self.owners.append(owner)
+                self.owners.append(owner)
 
         _desc = xml.findall('description')
         if _desc != None:


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

end of thread, other threads:[~2015-08-28  3:50 UTC | newest]

Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-14 15:15 [gentoo-commits] proj/layman:master commit in: layman/overlays/ Devan Franchini
  -- strict thread matches above, loose matches on Subject: below --
2015-08-28  3:50 Devan Franchini
2015-08-28  3:43 Devan Franchini
2015-08-28  0:41 Devan Franchini
2015-08-04  0:23 Devan Franchini
2015-07-21 16:39 Devan Franchini
2015-07-13 23:05 Devan Franchini
2015-07-13 19:04 Devan Franchini
2015-07-13 18:59 Devan Franchini
2015-07-13 18:52 Devan Franchini
2015-07-13 18:48 Devan Franchini
2015-07-10 16:13 Devan Franchini
2015-03-26 23:47 Devan Franchini
2015-03-26 23:08 Devan Franchini
2015-03-26 18:13 Devan Franchini
2014-12-08  4:15 Devan Franchini
2014-06-16  3:40 Brian Dolbec
2014-06-16  3:40 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: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: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: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-03-10  3:18 Brian Dolbec
2013-08-18 16:46 Brian Dolbec
2012-11-01  7:06 Brian Dolbec
2012-10-08  6:16 Brian Dolbec
2012-10-08  4:36 Brian Dolbec
2012-10-07 23:40 Brian Dolbec
2012-01-06  8:16 Brian Dolbec
2011-09-26  1:18 Brian Dolbec
2011-09-24  6:07 Brian Dolbec
2011-09-13 14:16 Brian Dolbec
2011-09-05 16:09 Brian Dolbec
2011-08-07  8:47 Brian Dolbec
2011-08-07  8:39 Brian Dolbec
2011-07-28 21:33 Brian Dolbec
2011-07-23  6:45 Brian Dolbec
2011-05-05  9:44 Brian Dolbec
2011-04-30 22:37 Brian Dolbec
2011-04-30  6:37 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-04-27 10:58 Brian Dolbec
2011-02-17 21:53 Brian Dolbec
2011-02-14  6:00 Brian Dolbec
2011-02-14  6:00 Brian Dolbec

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