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:

To download these repositories, get Mercurial and then type something like:

hg clone http://techn.ocracy.org/repository-name/

You can also click the "zip" or "gz" links to get an archive of the latest revision without installing anything.

The change logs of the repositories are aggregated at techn.ocracy.org/planet.

We have also some darcs repositories at techn.ocracy.org/darcs.