66 """ |
66 """ |
67 Protected method to dump an object of a basic Python type. |
67 Protected method to dump an object of a basic Python type. |
68 |
68 |
69 @param pyobject object to be dumped |
69 @param pyobject object to be dumped |
70 """ |
70 """ |
71 writeMethod = self.basics.get(type(pyobject)) or self._write_unimplemented |
71 writeMethod = self.basics.get(type(pyobject)) or \ |
|
72 self._write_unimplemented |
72 writeMethod(pyobject) |
73 writeMethod(pyobject) |
73 |
74 |
74 ############################################################################ |
75 ########################################################################### |
75 ## The various writer methods for basic types |
76 ## The various writer methods for basic types |
76 ############################################################################ |
77 ########################################################################### |
77 |
78 |
78 def _write_none(self, value): |
79 def _write_none(self, value): |
79 """ |
80 """ |
80 Protected method to dump a NoneType object. |
81 Protected method to dump a NoneType object. |
81 |
82 |
128 """ |
129 """ |
129 Protected method to dump a bytes object. |
130 Protected method to dump a bytes object. |
130 |
131 |
131 @param value value to be dumped (bytes) |
132 @param value value to be dumped (bytes) |
132 """ |
133 """ |
133 self.writeTextElement("bytes", ",".join(["{0:d}".format(b) for b in value])) |
134 self.writeTextElement( |
|
135 "bytes", ",".join(["{0:d}".format(b) for b in value])) |
134 |
136 |
135 def _write_bytearray(self, value): |
137 def _write_bytearray(self, value): |
136 """ |
138 """ |
137 Protected method to dump a bytearray object. |
139 Protected method to dump a bytearray object. |
138 |
140 |
139 @param value value to be dumped (bytearray) |
141 @param value value to be dumped (bytearray) |
140 """ |
142 """ |
141 self.writeTextElement("bytearray", ",".join(["{0:d}".format(b) for b in value])) |
143 self.writeTextElement( |
|
144 "bytearray", ",".join(["{0:d}".format(b) for b in value])) |
142 |
145 |
143 def _write_tuple(self, value): |
146 def _write_tuple(self, value): |
144 """ |
147 """ |
145 Protected method to dump a tuple object. |
148 Protected method to dump a tuple object. |
146 |
149 |
212 @param value value to be dumped (any pickleable object) |
215 @param value value to be dumped (any pickleable object) |
213 """ |
216 """ |
214 self.writeStartElement("pickle") |
217 self.writeStartElement("pickle") |
215 self.writeAttribute("method", "pickle") |
218 self.writeAttribute("method", "pickle") |
216 self.writeAttribute("encoding", "base64") |
219 self.writeAttribute("encoding", "base64") |
217 self.writeCharacters(str(base64.b64encode(pickle.dumps(value)), "ASCII")) |
220 self.writeCharacters( |
218 self.writeEndElement() |
221 str(base64.b64encode(pickle.dumps(value)), "ASCII")) |
|
222 self.writeEndElement() |