21 """ |
21 """ |
22 Constructor |
22 Constructor |
23 """ |
23 """ |
24 self.startDocumentSpecific = None |
24 self.startDocumentSpecific = None |
25 |
25 |
|
26 # TODO: add support for bytes, bytearray, set, frozenset |
26 self.elements = { |
27 self.elements = { |
27 'none' : (self.defaultStartElement, self.endNone), |
28 'none' : (self.defaultStartElement, self.endNone), |
28 'int' : (self.defaultStartElement, self.endInt), |
29 'int' : (self.defaultStartElement, self.endInt), |
29 'long' : (self.defaultStartElement, self.endLong), |
|
30 'float' : (self.defaultStartElement, self.endFloat), |
30 'float' : (self.defaultStartElement, self.endFloat), |
31 'complex' : (self.defaultStartElement, self.endComplex), |
31 'complex' : (self.defaultStartElement, self.endComplex), |
32 'bool' : (self.defaultStartElement, self.endBool), |
32 'bool' : (self.defaultStartElement, self.endBool), |
33 'string' : (self.defaultStartElement, self.endString), |
33 'string' : (self.defaultStartElement, self.endString), |
34 'unicode' : (self.defaultStartElement, self.endUnicode), |
|
35 'tuple' : (self.startTuple, self.endTuple), |
34 'tuple' : (self.startTuple, self.endTuple), |
36 'list' : (self.startList, self.endList), |
35 'list' : (self.startList, self.endList), |
37 'dict' : (self.startDictionary, self.endDictionary), |
36 'dict' : (self.startDictionary, self.endDictionary), |
38 'pickle' : (self.startPickle, self.endPickle), |
37 'pickle' : (self.startPickle, self.endPickle), |
|
38 # for backward compatibility |
|
39 'long' : (self.defaultStartElement, self.endInt), |
|
40 'unicode' : (self.defaultStartElement, self.endString), |
39 } |
41 } |
40 |
42 |
41 self.buffer = "" |
43 self.buffer = "" |
42 self.stack = [] |
44 self.stack = [] |
43 self._marker = '__MARKER__' |
45 self._marker = '__MARKER__' |
185 Handler method for the "string" end tag. |
181 Handler method for the "string" end tag. |
186 """ |
182 """ |
187 s = str(self.utf8_to_code(self.unescape(self.buffer))) |
183 s = str(self.utf8_to_code(self.unescape(self.buffer))) |
188 self.stack.append(s) |
184 self.stack.append(s) |
189 |
185 |
190 def endUnicode(self): |
186 ## def endUnicode(self): |
191 """ |
187 ## """ |
192 Handler method for the "unicode" end tag. |
188 ## Handler method for the "unicode" end tag. |
193 """ |
189 ## """ |
194 u = str(self.utf8_to_code(self.unescape(self.buffer))) |
190 ## u = str(self.utf8_to_code(self.unescape(self.buffer))) |
195 self.stack.append(u) |
191 ## self.stack.append(u) |
196 |
192 ## |
197 def startList(self, attrs): |
193 def startList(self, attrs): |
198 """ |
194 """ |
199 Handler method for the "list" start tag. |
195 Handler method for the "list" start tag. |
200 |
196 |
201 @param attrs list of tag attributes |
197 @param attrs list of tag attributes |