aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevan Franchini <twitch153@gentoo.org>2015-08-27 23:47:35 -0400
committerDevan Franchini <twitch153@gentoo.org>2015-08-27 23:47:38 -0400
commit4c8a81001eb813a4ec25584cacdd97c87f176c84 (patch)
treedcfdbd1c4ab7d47d1cacefb53cb52c1c260d233c
parentDeprecates get_all_info() function (diff)
downloadlayman-4c8a81001eb813a4ec25584cacdd97c87f176c84.tar.gz
layman-4c8a81001eb813a4ec25584cacdd97c87f176c84.tar.bz2
layman-4c8a81001eb813a4ec25584cacdd97c87f176c84.zip
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.
-rwxr-xr-xlayman/overlays/overlay.py49
1 files 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: