pyquery
changeset 77:8fc2caef7b4f
Allow to have Element as argument
| author | Gael Pasgrimaud <gael@gawel.org> |
|---|---|
| date | Sat Jan 24 02:58:46 2009 +0100 (18 months ago) |
| parents | e438752b3e14 |
| children | 85aa941b493b |
| files | pyquery/pyquery.py |
line diff
1.1 --- a/pyquery/pyquery.py Mon Dec 15 23:52:11 2008 +0100 1.2 +++ b/pyquery/pyquery.py Sat Jan 24 02:58:46 2009 +0100 1.3 @@ -522,13 +522,15 @@ 1.4 ################ 1.5 1.6 def _get_root(self, value): 1.7 - is_pyquery_results = isinstance(value, self.__class__) 1.8 - is_string = isinstance(value, basestring) 1.9 - assert is_string or is_pyquery_results, value 1.10 - if is_string: 1.11 + if isinstance(value, basestring): 1.12 root = etree.fromstring('<root>' + value + '</root>') 1.13 - elif is_pyquery_results: 1.14 + elif isinstance(value, etree._Element): 1.15 + root = self.__class__(value) 1.16 + elif isinstance(value, PyQuery): 1.17 root = value 1.18 + else: 1.19 + raise TypeError( 1.20 + 'Value must be string, PyQuery or Element. Got %r' % value) 1.21 if hasattr(root, 'text') and isinstance(root.text, basestring): 1.22 root_text = root.text 1.23 else:
