From 4c8a81001eb813a4ec25584cacdd97c87f176c84 Mon Sep 17 00:00:00 2001 From: Devan Franchini Date: Thu, 27 Aug 2015 23:47:35 -0400 Subject: 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: -- cgit v1.2.3-65-gdbad