E5XML/XMLStreamReaderBase.py

branch
Py2 comp.
changeset 3060
5883ce99ee12
parent 3058
0a02c433f52d
parent 3035
36e9f388958b
child 3145
a9de05d4a22f
equal deleted inserted replaced
3058:0a02c433f52d 3060:5883ce99ee12
52 if self.hasError(): 52 if self.hasError():
53 msg = QCoreApplication.translate( 53 msg = QCoreApplication.translate(
54 "XMLStreamReaderBase", 54 "XMLStreamReaderBase",
55 "<p>XML parse error in file <b>{0}</b>, line {1}," 55 "<p>XML parse error in file <b>{0}</b>, line {1},"
56 " column {2}</p><p>Error: {3}</p>").format( 56 " column {2}</p><p>Error: {3}</p>").format(
57 self.device().fileName(), 57 self.device().fileName(),
58 self.lineNumber(), self.columnNumber(), 58 self.lineNumber(), self.columnNumber(),
59 self.errorString()) 59 self.errorString())
60 E5MessageBox.warning( 60 E5MessageBox.warning(
61 None, 61 None,
62 QCoreApplication.translate( 62 QCoreApplication.translate(
63 "XMLStreamReaderBase", "XML parse error"), 63 "XMLStreamReaderBase", "XML parse error"),
64 msg) 64 msg)
65 65
66 def raiseUnexpectedStartTag(self, tag): 66 def raiseUnexpectedStartTag(self, tag):
67 """ 67 """
68 Public method to raise an error for an unexpected start tag. 68 Public method to raise an error for an unexpected start tag.
157 val = self.readElementText() 157 val = self.readElementText()
158 elif self.name() == "unicode": 158 elif self.name() == "unicode":
159 # backward compatibility to 4.6 159 # backward compatibility to 4.6
160 val = self.readElementText() 160 val = self.readElementText()
161 elif self.name() == "bytes": 161 elif self.name() == "bytes":
162 by = bytes([int(b) for b in 162 by = bytes([int(b) for b in
163 self.readElementText().split(",")]) 163 self.readElementText().split(",")])
164 val = by 164 val = by
165 elif self.name() == "bytearray": 165 elif self.name() == "bytearray":
166 by = bytearray([int(b) for b in 166 by = bytearray([int(b) for b in
167 self.readElementText().split(",")]) 167 self.readElementText().split(",")])
168 val = by 168 val = by
169 elif self.name() == "tuple": 169 elif self.name() == "tuple":
170 val = self.__readTuple() 170 val = self.__readTuple()
171 return val 171 return val
209 """ 209 """
210 Private method to read a Python tuple. 210 Private method to read a Python tuple.
211 211
212 @return Python tuple 212 @return Python tuple
213 """ 213 """
214 l = [] 214 li = []
215 while not self.atEnd(): 215 while not self.atEnd():
216 val = self._readBasics() 216 val = self._readBasics()
217 if self.isEndElement() and self.name() == "tuple" and val is None: 217 if self.isEndElement() and self.name() == "tuple" and val is None:
218 return tuple(l) 218 return tuple(li)
219 else: 219 else:
220 l.append(val) 220 li.append(val)
221 221
222 def __readList(self): 222 def __readList(self):
223 """ 223 """
224 Private method to read a Python list. 224 Private method to read a Python list.
225 225
226 @return Python list 226 @return Python list
227 """ 227 """
228 l = [] 228 li = []
229 while not self.atEnd(): 229 while not self.atEnd():
230 val = self._readBasics() 230 val = self._readBasics()
231 if self.isEndElement() and self.name() == "list" and val is None: 231 if self.isEndElement() and self.name() == "list" and val is None:
232 return l 232 return li
233 else: 233 else:
234 l.append(val) 234 li.append(val)
235 235
236 def __readDict(self): 236 def __readDict(self):
237 """ 237 """
238 Private method to read a Python dictionary. 238 Private method to read a Python dictionary.
239 239
257 """ 257 """
258 Private method to read a Python set. 258 Private method to read a Python set.
259 259
260 @return Python set 260 @return Python set
261 """ 261 """
262 l = [] 262 li = []
263 while not self.atEnd(): 263 while not self.atEnd():
264 val = self._readBasics() 264 val = self._readBasics()
265 if self.isEndElement() and self.name() == "set" and val is None: 265 if self.isEndElement() and self.name() == "set" and val is None:
266 return set(l) 266 return set(li)
267 else: 267 else:
268 l.append(val) 268 li.append(val)
269 269
270 def __readFrozenset(self): 270 def __readFrozenset(self):
271 """ 271 """
272 Private method to read a Python set. 272 Private method to read a Python set.
273 273
274 @return Python set 274 @return Python set
275 """ 275 """
276 l = [] 276 li = []
277 while not self.atEnd(): 277 while not self.atEnd():
278 val = self._readBasics() 278 val = self._readBasics()
279 if self.isEndElement() and \ 279 if self.isEndElement() and \
280 self.name() == "frozenset" and \ 280 self.name() == "frozenset" and \
281 val is None: 281 val is None:
282 return frozenset(l) 282 return frozenset(li)
283 else: 283 else:
284 l.append(val) 284 li.append(val)

eric ide

mercurial