| 1203 | ################ |
| 1204 | |
| 1205 | def _get_root(self, value): |
| 1206 | if isinstance(value, basestring): |
| 1207 | root = fromstring(u'<root>' + value + u'</root>', |
| 1208 | self.parser)[0] |
| 1209 | elif isinstance(value, etree._Element): |
| 1210 | root = self._copy(value) |
| 1211 | elif isinstance(value, PyQuery): |
| 1212 | root = value |
| 1213 | else: |
| 1214 | raise TypeError( |
| 1215 | 'Value must be string, PyQuery or Element. Got %r' % value) |
| 1216 | if hasattr(root, 'text') and isinstance(root.text, basestring): |
| 1217 | root_text = root.text |
| 1218 | else: |
| 1219 | root_text = '' |
| 1220 | return root, root_text |
| 1221 | |
| 1222 | def append(self, value): |
| 1223 | """append value to each nodes |