75 """ |
75 """ |
76 Protected method to dump an object of a basic Python type. |
76 Protected method to dump an object of a basic Python type. |
77 |
77 |
78 @param pyobject object to be dumped |
78 @param pyobject object to be dumped |
79 """ |
79 """ |
80 writeMethod = self.basics.get(type(pyobject)) or self._write_unimplemented |
80 writeMethod = self.basics.get(type(pyobject)) or \ |
|
81 self._write_unimplemented |
81 writeMethod(pyobject) |
82 writeMethod(pyobject) |
82 |
83 |
83 ############################################################################ |
84 ########################################################################### |
84 ## The various writer methods for basic types |
85 ## The various writer methods for basic types |
85 ############################################################################ |
86 ########################################################################### |
86 |
87 |
87 def _write_none(self, value): |
88 def _write_none(self, value): |
88 """ |
89 """ |
89 Protected method to dump a NoneType object. |
90 Protected method to dump a NoneType object. |
90 |
91 |
137 """ |
138 """ |
138 Protected method to dump a bytes object. |
139 Protected method to dump a bytes object. |
139 |
140 |
140 @param value value to be dumped (bytes) |
141 @param value value to be dumped (bytes) |
141 """ |
142 """ |
142 self.writeTextElement("bytes", ",".join(["{0:d}".format(b) for b in value])) |
143 self.writeTextElement( |
|
144 "bytes", ",".join(["{0:d}".format(b) for b in value])) |
143 |
145 |
144 def _write_bytearray(self, value): |
146 def _write_bytearray(self, value): |
145 """ |
147 """ |
146 Protected method to dump a bytearray object. |
148 Protected method to dump a bytearray object. |
147 |
149 |
148 @param value value to be dumped (bytearray) |
150 @param value value to be dumped (bytearray) |
149 """ |
151 """ |
150 self.writeTextElement("bytearray", ",".join(["{0:d}".format(b) for b in value])) |
152 self.writeTextElement( |
|
153 "bytearray", ",".join(["{0:d}".format(b) for b in value])) |
151 |
154 |
152 def _write_tuple(self, value): |
155 def _write_tuple(self, value): |
153 """ |
156 """ |
154 Protected method to dump a tuple object. |
157 Protected method to dump a tuple object. |
155 |
158 |
221 @param value value to be dumped (any pickleable object) |
224 @param value value to be dumped (any pickleable object) |
222 """ |
225 """ |
223 self.writeStartElement("pickle") |
226 self.writeStartElement("pickle") |
224 self.writeAttribute("method", "pickle") |
227 self.writeAttribute("method", "pickle") |
225 self.writeAttribute("encoding", "base64") |
228 self.writeAttribute("encoding", "base64") |
226 self.writeCharacters(str(base64.b64encode(pickle.dumps(value)), "ASCII")) |
229 self.writeCharacters( |
227 self.writeEndElement() |
230 str(base64.b64encode(pickle.dumps(value)), "ASCII")) |
|
231 self.writeEndElement() |