def _get_root(self, value):
        if  isinstance(value, basestring):
            root = fromstring(unicode('<root>') + value + unicode('</root>'), self.parser)[0]
        elif isinstance(value, etree._Element):
            root = self.__class__(value)
        elif isinstance(value, PyQuery):
            root = value
        else:
            raise TypeError(
            'Value must be string, PyQuery or Element. Got %r' %  value)
        if hasattr(root, 'text') and isinstance(root.text, basestring):
            root_text = root.text
        else:
            root_text = ''
        return root, root_text
dataset/ETHPy150Open dsc/pyquery/pyquery/pyquery.py/PyQuery._get_root/original