1 |
commit: 4c8a81001eb813a4ec25584cacdd97c87f176c84 |
2 |
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Aug 28 03:47:35 2015 +0000 |
4 |
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Aug 28 03:47:38 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=4c8a8100 |
7 |
|
8 |
overlay.py: Fixes method of assigning owner info if contact attrib is found |
9 |
|
10 |
Prior to this commit the overlay would not set the owner info if the |
11 |
contact attribute was found, breaking backwards compatibility. To allow |
12 |
for this backwards compatibility while maintaining multiple owner |
13 |
support layman will be defaulting to the "contact" attribute if it is |
14 |
present in any XML overlays. |
15 |
|
16 |
layman/overlays/overlay.py | 49 ++++++++++++++++++++++++---------------------- |
17 |
1 file changed, 26 insertions(+), 23 deletions(-) |
18 |
|
19 |
diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py |
20 |
index 8052d4c..9cbeb99 100755 |
21 |
--- a/layman/overlays/overlay.py |
22 |
+++ b/layman/overlays/overlay.py |
23 |
@@ -454,32 +454,35 @@ class Overlay(object): |
24 |
_owners = xml.findall('owner') |
25 |
self.owners = [] |
26 |
|
27 |
- for _owner in _owners: |
28 |
- owner = {} |
29 |
+ # For backwards compatibility with older Overlay XML formats |
30 |
+ # default to this. |
31 |
+ if 'contact' in xml.attrib: |
32 |
+ owner = {'email': encode(xml.attrib['contact']), |
33 |
+ 'name': None} |
34 |
+ self.owners.append(owner) |
35 |
+ else: |
36 |
+ for _owner in _owners: |
37 |
+ owner = {} |
38 |
|
39 |
- _email = _owner.find('email') |
40 |
- _name = _owner.find('name') |
41 |
+ _email = _owner.find('email') |
42 |
+ _name = _owner.find('name') |
43 |
|
44 |
- if _name != None: |
45 |
- owner['name'] = encode(strip_text(_name)) |
46 |
- else: |
47 |
- owner['name'] = None |
48 |
- if _email != None: |
49 |
- owner['email'] = encode(strip_text(_email)) |
50 |
- else: |
51 |
- owner['email'] = None |
52 |
- msg = 'Overlay from_xml(), "%(name)s" is missing an '\ |
53 |
- '"owner.email" entry!' % {'name': self.name} |
54 |
- if not ignore: |
55 |
- raise Exception(msg) |
56 |
- elif ignore == 1: |
57 |
- self.output.warn(msg, 4) |
58 |
+ if _name != None: |
59 |
+ owner['name'] = encode(strip_text(_name)) |
60 |
+ else: |
61 |
+ owner['name'] = None |
62 |
+ if _email != None: |
63 |
+ owner['email'] = encode(strip_text(_email)) |
64 |
+ else: |
65 |
+ owner['email'] = None |
66 |
+ msg = 'Overlay from_xml(), "%(name)s" is missing an '\ |
67 |
+ '"owner.email" entry!' % {'name': self.name} |
68 |
+ if not ignore: |
69 |
+ raise Exception(msg) |
70 |
+ elif ignore == 1: |
71 |
+ self.output.warn(msg, 4) |
72 |
|
73 |
- # For backwards compatibility with older Overlay XML formats. |
74 |
- if not _email and not _name and 'contact' in xml.attrib: |
75 |
- owner['email'] = encode(xml.attrib['contact']) |
76 |
- owner['name'] = None |
77 |
- self.owners.append(owner) |
78 |
+ self.owners.append(owner) |
79 |
|
80 |
_desc = xml.findall('description') |
81 |
if _desc != None: |