Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/
Date: Thu, 05 May 2011 09:44:25
Message-Id: e55554e5b5c6a9c95bb8ad56aab195df1fb35817.dol-sen@gentoo
1 commit: e55554e5b5c6a9c95bb8ad56aab195df1fb35817
2 Author: dol-sen <brian.dolbec <AT> gmail <DOT> com>
3 AuthorDate: Thu May 5 09:42:07 2011 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Thu May 5 09:42:07 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=e55554e5
7
8 fix a regression for the old xml format.
9 improve the Exception messages with the function name it originated in.
10
11 ---
12 layman/overlays/overlay.py | 46 ++++++++++++++++++++++++-------------------
13 1 files changed, 26 insertions(+), 20 deletions(-)
14
15 diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py
16 index dd2437c..d57fe22 100644
17 --- a/layman/overlays/overlay.py
18 +++ b/layman/overlays/overlay.py
19 @@ -122,11 +122,14 @@ class Overlay(object):
20 elif 'name' in xml.attrib:
21 self.name = ensure_unicode(xml.attrib['name'])
22 else:
23 - raise Exception('Overlay is missing a "name" entry!')
24 + raise Exception('Overlay from_xml(), "' + self.name + \
25 + 'is missing a "name" entry!')
26
27 _sources = xml.findall('source')
28 - if _sources != None:
29 + # new xml format
30 + if _sources != []:
31 _sources = [e for e in _sources if 'type' in e.attrib]
32 + #old xml format
33 elif ('src' in xml.attrib) and ('type' in xml.attrib):
34 s = ET.Element('source', type=xml.attrib['type'])
35 s.text = xml.attrib['src']
36 @@ -138,13 +141,14 @@ class Overlay(object):
37 try:
38 _class = OVERLAY_TYPES[_type]
39 except KeyError:
40 - raise Exception('Unknown overlay type "%s"!' % _type)
41 + raise Exception('Overlay from_xml(), "' + self.name + \
42 + 'Unknown overlay type "%s"!' % _type)
43 _location = ensure_unicode(strip_text(source_elem))
44 return _class(parent=self, config=self.config,
45 _location=_location, ignore=ignore, quiet=quiet)
46
47 if not len(_sources):
48 - raise Exception('Overlay "' + self.name + \
49 + raise Exception('Overlay from_xml(), "' + self.name + \
50 '" is missing a "source" entry!')
51
52 self.sources = [create_overlay_source(e) for e in _sources]
53 @@ -176,8 +180,8 @@ class Overlay(object):
54 self.owner_email = ''
55 self.owner_name = None
56 if not ignore:
57 - raise Exception('Overlay "' + self.name + '" is missing a '
58 - '"owner.email" entry!')
59 + raise Exception('Overlay from_xml(), "' + self.name + \
60 + '" is missing an "owner.email" entry!')
61 elif ignore == 1:
62 self.output.warn('Overlay "' + self.name + '" is missing a '
63 '"owner.email" entry!', 4)
64 @@ -190,8 +194,8 @@ class Overlay(object):
65 else:
66 self.description = ''
67 if not ignore:
68 - raise Exception('Overlay "' + self.name + '" is missing a '
69 - '"description" entry!')
70 + raise Exception('Overlay from_xml(), "' + self.name + \
71 + '" is missing a description" entry!')
72 elif ignore == 1:
73 self.output.warn('Overlay "' + self.name + '" is missing a '
74 '"description" entry!', 4)
75 @@ -233,17 +237,18 @@ class Overlay(object):
76 def from_dict(self, overlay, ignore, quiet):
77 """Process an xml overlay definition
78 """
79 - self.output.debug("Overlay.from_dict; overlay" + str(overlay))
80 + self.output.debug("Overlay from_dict(); overlay" + str(overlay))
81 _name = overlay['name']
82 if _name != None:
83 self.name = ensure_unicode(_name)
84 else:
85 - raise Exception('Overlay is missing a "name" entry!')
86 + raise Exception('Overlay from_dict(), "' + self.name +
87 + 'is missing a "name" entry!')
88
89 _sources = overlay['sources']
90
91 if _sources == None:
92 - raise Exception('Overlay "' + self.name +
93 + raise Exception('Overlay from_dict(), "' + self.name +
94 '" is missing a "source" entry!')
95
96 def create_dict_overlay_source(source_):
97 @@ -251,7 +256,8 @@ class Overlay(object):
98 try:
99 _class = OVERLAY_TYPES[_type]
100 except KeyError:
101 - raise Exception('Unknown overlay type "%s"!' % _type)
102 + raise Exception('Overlay from_dict(), "' + self.name +
103 + 'Unknown overlay type "%s"!' % _type)
104 _location = ensure_unicode(_src)
105 return _class(parent=self, config=self.config,
106 _location=_location, ignore=ignore, quiet=quiet)
107 @@ -270,11 +276,11 @@ class Overlay(object):
108 else:
109 self.owner_email = None
110 if not ignore:
111 - raise Exception('Overlay "' + self.name + '" is missing a '
112 - '"owner.email" entry!')
113 + raise Exception('Overlay from_dict(), "' + self.name +
114 + '" is missing an "owner.email" entry!')
115 elif ignore == 1:
116 - self.output.warn('Overlay "' + self.name + '" is missing a '
117 - '"owner.email" entry!', 4)
118 + self.output.warn('Overlay from_dict(), "' + self.name +
119 + '" is missing an "owner.email" entry!', 4)
120
121 _desc = overlay['description']
122 if _desc != None:
123 @@ -284,11 +290,11 @@ class Overlay(object):
124 else:
125 self.description = ''
126 if not ignore:
127 - raise Exception('Overlay "' + self.name + '" is missing a '
128 - '"description" entry!')
129 + raise Exception('Overlay from_dict(), "' + self.name +
130 + '" is missing a "description" entry!')
131 elif ignore == 1:
132 - self.output.warn('Overlay "' + self.name + '" is missing a '
133 - '"description" entry!', 4)
134 + self.output.warn('Overlay from_dict(), "' + self.name +
135 + '" is missing a "description" entry!', 4)
136
137 if overlay['status']:
138 self.status = ensure_unicode(overlay['status'])