Mercurial > libervia-backend
comparison tools/memory.py @ 34:a544b376b6f0
use proper utf-8 encoding for parsing xml in parameters
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 13 Dec 2009 18:36:20 +1100 |
parents | bb72c29f3432 |
children | 3e24753b9e0b |
comparison
equal
deleted
inserted
replaced
33:b9bb5d8e0cc7 | 34:a544b376b6f0 |
---|---|
35 class Param(): | 35 class Param(): |
36 """This class manage parameter with xml""" | 36 """This class manage parameter with xml""" |
37 ### TODO: add desciption in params | 37 ### TODO: add desciption in params |
38 | 38 |
39 #TODO: mettre Watched dans un plugin | 39 #TODO: mettre Watched dans un plugin |
40 default_xml = """ | 40 default_xml = u""" |
41 <params> | 41 <params> |
42 <category name="Connection"> | 42 <category name="Connection"> |
43 <param name="JabberID" value="goffi@necton2.int/TestScript" type="string" /> | 43 <param name="JabberID" value="goffi@necton2.int/TestScript" type="string" /> |
44 <param name="Password" value="toto" type="password" /> | 44 <param name="Password" value="toto" type="password" /> |
45 <param name="Server" value="necton2.int" type="string" /> | 45 <param name="Server" value="necton2.int" type="string" /> |
50 </category> | 50 </category> |
51 </params> | 51 </params> |
52 """ | 52 """ |
53 | 53 |
54 def load_default_params(self): | 54 def load_default_params(self): |
55 self.dom = minidom.parseString(Param.default_xml) | 55 self.dom = minidom.parseString(Param.default_xml.encode('utf-8')) |
56 | 56 |
57 def __init__(self, host): | 57 def __init__(self, host): |
58 debug("Parameters init") | 58 debug("Parameters init") |
59 self.host = host | 59 self.host = host |
60 self.load_default_params() | 60 self.load_default_params() |
76 | 76 |
77 def importParams(self, parent, xml): | 77 def importParams(self, parent, xml): |
78 """import xml in parameters, do nothing if the param already exist | 78 """import xml in parameters, do nothing if the param already exist |
79 @param parent: parent class (usefull for callbacks) | 79 @param parent: parent class (usefull for callbacks) |
80 @param xml: parameters in xml form""" | 80 @param xml: parameters in xml form""" |
81 src_dom = minidom.parseString(xml) | 81 src_dom = minidom.parseString(xml.encode('utf-8')) |
82 | 82 |
83 def import_node(tgt_parent, src_parent): | 83 def import_node(tgt_parent, src_parent): |
84 for child in src_parent.childNodes: | 84 for child in src_parent.childNodes: |
85 if child.nodeName == '#text': | 85 if child.nodeName == '#text': |
86 continue | 86 continue |