MCPcopy Create free account
hub / github.com/gawel/pyquery / _get_root

Method _get_root

pyquery/pyquery.py:1205–1220  ·  view source on GitHub ↗
(self, value)

Source from the content-addressed store, hash-verified

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

Callers 4

appendMethod · 0.95
prependMethod · 0.95
afterMethod · 0.95
beforeMethod · 0.95

Calls 2

_copyMethod · 0.95
fromstringFunction · 0.85

Tested by

no test coverage detected