155 val = self.readElementText() |
155 val = self.readElementText() |
156 elif self.name() == "unicode": |
156 elif self.name() == "unicode": |
157 # backward compatibility to 4.6 |
157 # backward compatibility to 4.6 |
158 val = self.readElementText() |
158 val = self.readElementText() |
159 elif self.name() == "bytes": |
159 elif self.name() == "bytes": |
160 by = bytes([int(b) for b in |
160 by = bytes([int(b) for b in |
161 self.readElementText().split(",")]) |
161 self.readElementText().split(",")]) |
162 val = by |
162 val = by |
163 elif self.name() == "bytearray": |
163 elif self.name() == "bytearray": |
164 by = bytearray([int(b) for b in |
164 by = bytearray([int(b) for b in |
165 self.readElementText().split(",")]) |
165 self.readElementText().split(",")]) |
166 val = by |
166 val = by |
167 elif self.name() == "tuple": |
167 elif self.name() == "tuple": |
168 val = self.__readTuple() |
168 val = self.__readTuple() |
169 return val |
169 return val |
207 """ |
207 """ |
208 Private method to read a Python tuple. |
208 Private method to read a Python tuple. |
209 |
209 |
210 @return Python tuple |
210 @return Python tuple |
211 """ |
211 """ |
212 l = [] |
212 li = [] |
213 while not self.atEnd(): |
213 while not self.atEnd(): |
214 val = self._readBasics() |
214 val = self._readBasics() |
215 if self.isEndElement() and self.name() == "tuple" and val is None: |
215 if self.isEndElement() and self.name() == "tuple" and val is None: |
216 return tuple(l) |
216 return tuple(li) |
217 else: |
217 else: |
218 l.append(val) |
218 li.append(val) |
219 |
219 |
220 def __readList(self): |
220 def __readList(self): |
221 """ |
221 """ |
222 Private method to read a Python list. |
222 Private method to read a Python list. |
223 |
223 |
224 @return Python list |
224 @return Python list |
225 """ |
225 """ |
226 l = [] |
226 li = [] |
227 while not self.atEnd(): |
227 while not self.atEnd(): |
228 val = self._readBasics() |
228 val = self._readBasics() |
229 if self.isEndElement() and self.name() == "list" and val is None: |
229 if self.isEndElement() and self.name() == "list" and val is None: |
230 return l |
230 return li |
231 else: |
231 else: |
232 l.append(val) |
232 li.append(val) |
233 |
233 |
234 def __readDict(self): |
234 def __readDict(self): |
235 """ |
235 """ |
236 Private method to read a Python dictionary. |
236 Private method to read a Python dictionary. |
237 |
237 |
255 """ |
255 """ |
256 Private method to read a Python set. |
256 Private method to read a Python set. |
257 |
257 |
258 @return Python set |
258 @return Python set |
259 """ |
259 """ |
260 l = [] |
260 li = [] |
261 while not self.atEnd(): |
261 while not self.atEnd(): |
262 val = self._readBasics() |
262 val = self._readBasics() |
263 if self.isEndElement() and self.name() == "set" and val is None: |
263 if self.isEndElement() and self.name() == "set" and val is None: |
264 return set(l) |
264 return set(li) |
265 else: |
265 else: |
266 l.append(val) |
266 li.append(val) |
267 |
267 |
268 def __readFrozenset(self): |
268 def __readFrozenset(self): |
269 """ |
269 """ |
270 Private method to read a Python set. |
270 Private method to read a Python set. |
271 |
271 |
272 @return Python set |
272 @return Python set |
273 """ |
273 """ |
274 l = [] |
274 li = [] |
275 while not self.atEnd(): |
275 while not self.atEnd(): |
276 val = self._readBasics() |
276 val = self._readBasics() |
277 if self.isEndElement() and \ |
277 if self.isEndElement() and \ |
278 self.name() == "frozenset" and \ |
278 self.name() == "frozenset" and \ |
279 val is None: |
279 val is None: |
280 return frozenset(l) |
280 return frozenset(li) |
281 else: |
281 else: |
282 l.append(val) |
282 li.append(val) |