comparison src/tools/xml_tools.py @ 684:969562c4761b

core (tools): small fix in using imported methods
author souliane <souliane@mailoo.org>
date Thu, 24 Oct 2013 08:47:45 +0200
parents 69a8bfd266a5
children f021bf27a557
comparison
equal deleted inserted replaced
683:75e4f5e2cc65 684:969562c4761b
15 # GNU Affero General Public License for more details. 15 # GNU Affero General Public License for more details.
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from logging import debug, info, error 20 from logging import debug, info, error, warning
21 from xml.dom import minidom 21 from xml.dom import minidom
22 from wokkel import data_form 22 from wokkel import data_form
23 from twisted.words.xish import domish 23 from twisted.words.xish import domish
24 from sat.core import exceptions 24 from sat.core import exceptions
25 25
82 label = elt.attributes.get('label','') 82 label = elt.attributes.get('label','')
83 type_ = elt.attributes.get('type','') # TODO 83 type_ = elt.attributes.get('type','') # TODO
84 headers.append(Header(name, label)) 84 headers.append(Header(name, label))
85 85
86 if not headers: 86 if not headers:
87 raise DataError("No reported fields (see XEP-0004 §3.4)") 87 raise exceptions.DataError("No reported fields (see XEP-0004 §3.4)")
88 88
89 item_elts = form_xml.elements('jabber:x:data', 'item') 89 item_elts = form_xml.elements('jabber:x:data', 'item')
90 90
91 for item_elt in item_elts: 91 for item_elt in item_elts:
92 fields = [] 92 fields = []
95 warning("Unexpected tag (%s)" % elt.name) 95 warning("Unexpected tag (%s)" % elt.name)
96 continue 96 continue
97 name = elt['var'] 97 name = elt['var']
98 child_elt = elt.firstChildElement() 98 child_elt = elt.firstChildElement()
99 if child_elt.name != "value": 99 if child_elt.name != "value":
100 raise DataError('Was expecting <value> tag') 100 raise exceptions.DataError('Was expecting <value> tag')
101 value = unicode(child_elt) 101 value = unicode(child_elt)
102 fields.append(Field(name, value)) 102 fields.append(Field(name, value))
103 items.append(Item(' | '.join((field.value for field in fields if field)), fields)) 103 items.append(Item(' | '.join((field.value for field in fields if field)), fields))
104 104
105 return form_ui.addAdvancedList(None, headers, items) 105 return form_ui.addAdvancedList(None, headers, items)