From 4e5db6241219e5daf79ac20967aef03097d70bb8 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Tue, 29 Dec 2009 13:35:33 +0100 Subject: Pass config down to Overlay instances --- layman/db.py | 11 ++++++----- layman/overlay.py | 16 +++++++++------- layman/overlays/bzr.py | 4 ++++ layman/overlays/cvs.py | 4 ++-- layman/overlays/darcs.py | 4 ++++ layman/overlays/git.py | 4 ++++ layman/overlays/mercurial.py | 4 ++++ layman/overlays/overlay.py | 11 ++++++----- layman/overlays/rsync.py | 4 ++++ layman/overlays/svn.py | 4 ++++ layman/overlays/tar.py | 4 ++-- 11 files changed, 49 insertions(+), 21 deletions(-) diff --git a/layman/db.py b/layman/db.py index 61c0944..db4a4c5 100644 --- a/layman/db.py +++ b/layman/db.py @@ -54,7 +54,8 @@ class DB(Overlays): quiet = int(config['quietness']) < 3 Overlays.__init__(self, - [config['local_list'], ], + [config['local_list'], ], + config, ignore, quiet) @@ -89,7 +90,7 @@ class DB(Overlays): # >>> b.add(a.select('wrobel-stable')) #doctest: +ELLIPSIS # * Running command "/usr/bin/rsync -rlptDvz --progress --delete --delete-after --timeout=180 --exclude="distfiles/*" --exclude="local/*" --exclude="packages/*" "rsync://gunnarwrobel.de/wrobel-stable/*" "/tmp/file.../wrobel-stable""... - # >>> c = Overlays([write, ]) + # >>> c = Overlays([write, ], dict()) # >>> c.overlays.keys() # [u'wrobel-stable'] @@ -156,12 +157,12 @@ class DB(Overlays): # * Running command "/usr/bin/rsync -rlptDvz --progress --delete --delete-after --timeout=180 --exclude="distfiles/*" --exclude="local/*" --exclude="packages/*" "rsync://gunnarwrobel.de/wrobel-stable/*" "/tmp/file.../wrobel-stable""... # >>> b.add(a.select('wrobel')) #doctest: +ELLIPSIS # * Running command "/usr/bin/svn co "https://overlays.gentoo.org/svn/dev/wrobel/" "/tmp/file.../wrobel""... - # >>> c = Overlays([write, ]) + # >>> c = Overlays([write, ], dict()) # >>> c.overlays.keys() # [u'wrobel', u'wrobel-stable'] # >>> b.delete(b.select('wrobel')) - # >>> c = Overlays([write, ]) + # >>> c = Overlays([write, ], dict()) # >>> c.overlays.keys() # [u'wrobel-stable'] @@ -234,7 +235,7 @@ class RemoteDB(Overlays): quiet = int(config['quietness']) < 3 - Overlays.__init__(self, paths, ignore, quiet) + Overlays.__init__(self, paths, config, ignore, quiet) def cache(self): ''' diff --git a/layman/overlay.py b/layman/overlay.py index 37e611c..d2126a8 100644 --- a/layman/overlay.py +++ b/layman/overlay.py @@ -69,8 +69,9 @@ OVERLAY_TYPES = dict((e.type_key, e) for e in ( class Overlays: ''' Handle a list of overlays.''' - def __init__(self, paths, ignore = 0, quiet = False): + def __init__(self, paths, config, ignore = 0, quiet = False): + self.config = config self.quiet = quiet self.paths = paths self.ignore = ignore @@ -101,7 +102,7 @@ class Overlays: >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ]) + >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict()) >>> a.overlays.keys() [u'wrobel', u'wrobel-stable'] @@ -127,6 +128,7 @@ class Overlays: if overlay_type in OVERLAY_TYPES.keys(): try: ovl = OVERLAY_TYPES[overlay_type](overlay, + self.config, self.ignore, self.quiet) self.overlays[ovl.name] = ovl @@ -144,11 +146,11 @@ class Overlays: >>> write = os.tmpnam() >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ]) - >>> b = Overlays([write,]) + >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict()) + >>> b = Overlays([write,], dict()) >>> b.overlays['wrobel-stable'] = a.overlays['wrobel-stable'] >>> b.write(write) - >>> c = Overlays([write,]) + >>> c = Overlays([write,], dict()) >>> c.overlays.keys() [u'wrobel-stable'] @@ -175,7 +177,7 @@ class Overlays: Select an overlay from the list. >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ]) + >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict()) >>> a.select('wrobel-stable').src u'rsync://gunnarwrobel.de/wrobel-stable' ''' @@ -187,7 +189,7 @@ class Overlays: List all overlays. >>> here = os.path.dirname(os.path.realpath(__file__)) - >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ]) + >>> a = Overlays([here + '/tests/testfiles/global-overlays.xml', ], dict()) >>> for i in a.list(True): ... print i[0] wrobel diff --git a/layman/overlays/bzr.py b/layman/overlays/bzr.py index 64fbbdd..047d944 100644 --- a/layman/overlays/bzr.py +++ b/layman/overlays/bzr.py @@ -43,6 +43,10 @@ class BzrOverlay(Overlay): binary_command = '/usr/bin/bzr' + def __init__(self, xml, config, ignore = 0, quiet = False): + + Overlay.__init__(self, xml, config, ignore) + def add(self, base, quiet = False): '''Add overlay.''' diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py index a28889a..fa67871 100644 --- a/layman/overlays/cvs.py +++ b/layman/overlays/cvs.py @@ -41,9 +41,9 @@ class CvsOverlay(Overlay): binary = '/usr/bin/cvs' - def __init__(self, xml, ignore = 0, quiet = False): + def __init__(self, xml, config, ignore = 0, quiet = False): - Overlay.__init__(self, xml, ignore, quiet) + Overlay.__init__(self, xml, config, ignore, quiet) if 'subpath' in xml.attrib: self.subpath = xml.attrib['subpath'] diff --git a/layman/overlays/darcs.py b/layman/overlays/darcs.py index e066eee..de23248 100644 --- a/layman/overlays/darcs.py +++ b/layman/overlays/darcs.py @@ -42,6 +42,10 @@ class DarcsOverlay(Overlay): binary_command = '/usr/bin/darcs' + def __init__(self, xml, config, ignore = 0, quiet = False): + + Overlay.__init__(self, xml, config, ignore) + def add(self, base, quiet = False): '''Add overlay.''' diff --git a/layman/overlays/git.py b/layman/overlays/git.py index 3bcb3e3..ece0de3 100644 --- a/layman/overlays/git.py +++ b/layman/overlays/git.py @@ -41,6 +41,10 @@ class GitOverlay(Overlay): binary_command = '/usr/bin/git' + def __init__(self, xml, config, ignore = 0, quiet = False): + + Overlay.__init__(self, xml, config, ignore) + def add(self, base, quiet = False): '''Add overlay.''' diff --git a/layman/overlays/mercurial.py b/layman/overlays/mercurial.py index 03af63b..9e0c5e7 100644 --- a/layman/overlays/mercurial.py +++ b/layman/overlays/mercurial.py @@ -42,6 +42,10 @@ class MercurialOverlay(Overlay): binary_command = '/usr/bin/hg' + def __init__(self, xml, config, ignore = 0, quiet = False): + + Overlay.__init__(self, xml, config, ignore) + def add(self, base, quiet = False): '''Add overlay.''' diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index aef4fe9..580ff47 100644 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -46,13 +46,13 @@ class Overlay: type = 'None' - def __init__(self, xml, ignore = 0, quiet = False): + def __init__(self, xml, config, 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') >>> overlays = document.findall('overlay') + document.findall('repo') - >>> a = Overlay(overlays[0]) + >>> a = Overlay(overlays[0], dict()) >>> a.name u'wrobel' >>> a.is_official() @@ -65,10 +65,11 @@ class Overlay: u'Test' >>> a.priority 10 - >>> b = Overlay(overlays[1]) + >>> b = Overlay(overlays[1], dict()) >>> b.is_official() False ''' + self.config = config self.quiet = quiet _name = xml.find('name') @@ -231,7 +232,7 @@ class Overlay: >>> import xml.etree.ElementTree as ET # Python 2.5 >>> document = ET.parse(here + '/../tests/testfiles/global-overlays.xml') >>> overlays = document.findall('overlay') + document.findall('repo') - >>> a = Overlay(overlays[0]) + >>> a = Overlay(overlays[0], dict()) >>> print str(a) wrobel ~~~~~~ @@ -279,7 +280,7 @@ class Overlay: >>> import xml.etree.ElementTree as ET # Python 2.5 >>> document = ET.parse(here + '/../tests/testfiles/global-overlays.xml') >>> overlays = document.findall('repo') + document.findall('overlay') - >>> a = Overlay(overlays[0]) + >>> a = Overlay(overlays[0], dict()) >>> print a.short_list(80) wrobel [None ] (https://o.g.o/svn/dev/wrobel ) ''' diff --git a/layman/overlays/rsync.py b/layman/overlays/rsync.py index 1fc767f..936a15d 100644 --- a/layman/overlays/rsync.py +++ b/layman/overlays/rsync.py @@ -45,6 +45,10 @@ class RsyncOverlay(Overlay): '--timeout=180 --exclude="distfiles/*" --exclude="local/*" ' + \ '--exclude="packages/*" ' + def __init__(self, xml, config, ignore = 0, quiet = False): + + Overlay.__init__(self, xml, config, ignore) + def add(self, base, quiet = False): '''Add overlay.''' diff --git a/layman/overlays/svn.py b/layman/overlays/svn.py index 8fef998..6c41569 100644 --- a/layman/overlays/svn.py +++ b/layman/overlays/svn.py @@ -41,6 +41,10 @@ class SvnOverlay(Overlay): binary = '/usr/bin/svn' + def __init__(self, xml, config, ignore = 0, quiet = False): + + Overlay.__init__(self, xml, config, ignore) + def add(self, base, quiet = False): '''Add overlay.''' diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py index 4990b2b..26010e0 100644 --- a/layman/overlays/tar.py +++ b/layman/overlays/tar.py @@ -66,9 +66,9 @@ class TarOverlay(Overlay): binary = u'/bin/tar' - def __init__(self, xml, ignore = 0, quiet = False): + def __init__(self, xml, config, ignore = 0, quiet = False): - Overlay.__init__(self, xml, ignore) + Overlay.__init__(self, xml, config, ignore) if 'format' in xml.attrib: self.format = xml.attrib['format'] -- cgit v1.2.3-1-g7c22