How to use the thug.DOM.W3C.Core.DOMImplementation.DOMImplementation.createHTMLElement function in thug

To help you get started, we’ve selected a few thug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buffer / thug / thug / DOM / W3C / Core / NodeList.py View on Github external
def item(self, index):
        from .DOMImplementation import DOMImplementation
        return DOMImplementation.createHTMLElement(self.doc, self.nodes[index]) if index >= 0 and index < len(self.nodes) else None
github buffer / thug / thug / DOM / W3C / Core / Document.py View on Github external
def match_tag(tag, _id):
            if _match_tag(tag, _id):
                return True

            return False

        def filter_tags_id(tag):
            return tag.has_attr('id')

        def filter_tags_name(tag):
            return tag.has_attr('name')

        for tag in self.doc.find_all(filter_tags_id):
            if match_tag(tag, 'id'):
                return DOMImplementation.createHTMLElement(self, tag)

        for tag in self.doc.find_all(filter_tags_name):
            if match_tag(tag, 'name'):
                return DOMImplementation.createHTMLElement(self, tag)

        return None
github buffer / thug / thug / DOM / W3C / HTML / xpath_property.py View on Github external
children = getChildren(self.doc, parts)

        if xpath == '/html/body[1]' and not children:
            children = [self.doc]

        if parts[-1] == 'text()':
            return "".join(children)

        m = RE_INDEXED.match(parts[-1])

        if m:
            try:
                from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation
                string.atoi(m.group(2))

                return DOMImplementation.createHTMLElement(self.doc, children[0]) if len(children) > 0 else None
            except ValueError:
                pass

        return HTMLCollection(self.doc, children)
github buffer / thug / thug / DOM / W3C / Core / Node.py View on Github external
def wrap(doc, obj):
        from .DOMImplementation import DOMImplementation

        if obj is None:
            return None

        if isinstance(obj, BeautifulSoup.CData):
            from .CDATASection import CDATASection
            return CDATASection(doc, obj)

        if isinstance(obj, BeautifulSoup.NavigableString):
            from .Text import Text
            return Text(doc, obj)

        return DOMImplementation.createHTMLElement(doc, obj)
github buffer / thug / thug / DOM / W3C / HTML / HTMLCollection.py View on Github external
def item(self, index):
        from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation

        if index < 0 or index >= self.length:
            return None

        if isinstance(self.nodes[index], bs4.element.Tag):
            return DOMImplementation.createHTMLElement(self.doc, self.nodes[index])

        return self.nodes[index]
github buffer / thug / thug / DOM / DFT.py View on Github external
else:
            try:
                handler = getattr(self.context.locals, h, None)
            except Exception:
                handler = None

        if not handler: # pragma: no cover
            return

        if getattr(elem, 'name', None) and elem.name in ('body', ) and evt in self.window_on_events:
            setattr(self.window, evt, handler)
            return

        if not getattr(elem, '_node', None):
            from thug.DOM.W3C.Core.DOMImplementation import DOMImplementation
            DOMImplementation.createHTMLElement(self.window.doc, elem)

        elem._node._attachEvent(evt, handler, True)