diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2010-01-04 05:47:18 +0100 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2010-01-04 05:51:42 +0100 |
commit | e54bec19b0a5e29df79b35d0f90574e22db538da (patch) | |
tree | d70bd3ef11897245e8e0359cf4f62004655fc93a | |
parent | Notify subclasses of Overlay which <source> is selected (diff) | |
download | layman-e54bec19b0a5e29df79b35d0f90574e22db538da.tar.gz layman-e54bec19b0a5e29df79b35d0f90574e22db538da.tar.bz2 layman-e54bec19b0a5e29df79b35d0f90574e22db538da.zip |
Add reading of format/subpath/category from repositories.xml format
-rw-r--r-- | layman/overlays/cvs.py | 9 | ||||
-rw-r--r-- | layman/overlays/tar.py | 40 |
2 files changed, 33 insertions, 16 deletions
diff --git a/layman/overlays/cvs.py b/layman/overlays/cvs.py index d2bf5d3..5c8d376 100644 --- a/layman/overlays/cvs.py +++ b/layman/overlays/cvs.py @@ -26,7 +26,7 @@ __version__ = "$Id$" import xml.etree.ElementTree as ET # Python 2.5 -from layman.utils import path +from layman.utils import path, ensure_unicode from layman.overlays.overlay import Overlay #=============================================================================== @@ -45,8 +45,11 @@ class CvsOverlay(Overlay): Overlay.__init__(self, xml, config, ignore, quiet) - if 'subpath' in xml.attrib: - self.subpath = xml.attrib['subpath'] + _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 = '' diff --git a/layman/overlays/tar.py b/layman/overlays/tar.py index 05b8581..2f9f862 100644 --- a/layman/overlays/tar.py +++ b/layman/overlays/tar.py @@ -27,7 +27,7 @@ __version__ = "$Id: tar.py 310 2007-04-09 16:30:40Z wrobel $" import os, os.path, sys, urllib2, shutil import xml.etree.ElementTree as ET # Python 2.5 -from layman.utils import path +from layman.utils import path, ensure_unicode from layman.overlays.overlay import Overlay #=============================================================================== @@ -70,25 +70,30 @@ class TarOverlay(Overlay): Overlay.__init__(self, xml, config, ignore) - if 'format' in xml.attrib: - self.format = xml.attrib['format'] - else: - self.format = '' + # Handle attribute format of old layman-global.txt format + # See _set_source() for repositories.xml variant + if not self.format and 'format' in xml.attrib: + self.format = ensure_unicode(xml.attrib['format']) - if 'subpath' in xml.attrib: - self.subpath = xml.attrib['subpath'] + _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 = '' - if 'category' in xml.attrib: - if self.subpath: - raise Exception('Cannot use "category" and "subpath" at the same' - ' time!') - - self.category = xml.attrib['category'] + _category = xml.find('category') + if _category != None: + self.category = ensure_unicode(_category.text.strip()) + elif 'category' in xml.attrib: + self.category = ensure_unicode(xml.attrib['category']) else: self.category = '' + if self.subpath and self.category: + raise Exception('Cannot use "category" and "subpath" at the same time!') + def __eq__(self, other): res = super(TarOverlay, self).__eq__(other) \ and self.format == other.format \ @@ -100,6 +105,15 @@ class TarOverlay(Overlay): return not self.__eq__(other) # overrider + def _set_source(self, source_elem): + # Handle attribute format of new repositories.xml format + if 'format' in source_elem.attrib: + self.format = ensure_unicode(source_elem.attrib['format']) + else: + self.format = '' + super(TarOverlay, self)._set_source(source_elem) + + # overrider def to_xml(self): repo = super(TarOverlay, self).to_xml() if self.format: |