Convert a regular :term:`chainlink` to a thread based version

    :param element: the chainlink to convert
    :return: a threaded version of ``element`` if possible, or the element itself
483927
def convert(element):
    
    element = linker.LinkPrimitives().convert(element)
    if isinstance(element, link.ChainLink.chain_types.base_bundle_type):
        return ThreadLinkPrimitives.base_bundle_type(element.elements)
    elif isinstance(element, link.ChainLink.chain_types.base_chain_type):
        return ThreadLinkPrimitives.base_chain_type(element.elements)
    return element
770424
def get_web_element(self, element):
        
        from toolium.pageelements.page_element import PageElement
        if isinstance(element, WebElement):
            web_element = element
        elif isinstance(element, PageElement):
            web_element = element.web_element
        elif isinstance(element, tuple):
            web_element = self.driver_wrapper.driver.find_element(*element)
        else:
            web_element = None
        return web_element
204469
def send_an_element(self, element):
        
        # Comment this log because it raises an encoding exception on Travis CI with python 2.7!
        # logger.debug("Sending to %s for %s", self.daemon, element)
        if hasattr(self.daemon, "add"):
            func = getattr(self.daemon, "add")
            if isinstance(func, collections.Callable):
                try:
                    func(element)
                except Exception as exp:  # pylint: disable=broad-except
                    logger.critical("Daemon report exception: %s", exp)
                return

        logger.critical("External command or Brok could not be sent to any daemon!")
810066
def select(self, element):
        
        self._field.validate_value(element)
        self._elements.add(element)
        self._sync_field()
1203375
def _send_xmpp_element(self, xmpp_element: XMPPElement):
        
        while not self.connected:
            log.debug("[!] Waiting for connection.")
            time.sleep(0.1)

        self.loop.call_soon_threadsafe(self.connection.send_raw_data, (xmpp_element.serialize()))
        return xmpp_element.message_id
1243424
def element_repr(self):
    
    # deepcopy so we don't mess with the valid XML.
    pretty_data = copy.deepcopy(self)
    indent_xml(pretty_data)
    return ElementTree.tostring(pretty_data).encode("utf-8")
843941
def Element(self, elem, **params):
        """"""
        res = self.__call__(deepcopy(elem), **params)
        if len(res) > 0: 
            return res[0]
        else:
            return None
651639
def chain(cls, *iterables):
    

    def generator():
      for it in iterables:
        for element in it:
          yield element
    return cls(generator())
681376
def __process_url_wrapper_elements(self, elements):
        
        urls = ''
        for url_wrapper, articles in elements:
            urls += self.__create_url_node_for_content(
                url_wrapper,
                'others',
                url=urljoin(self.url_site, url_wrapper.url),
                modification_time=self.__get_date_key(sorted(articles, key=self.__get_date_key, reverse=True)[0])
            )
        return urls
858495
def convert_node(self, node):
        
        convert = getattr(self, 'convert_' + striptag(node.tag))
        return convert(node)
608058
def iter_links_object_element(cls, element):
        '''
        '''
        base_link = element.attrib.get('codebase', None)

        if base_link:
            # lxml returns codebase as inline
            link_type = element.attrib.get(base_link)
            yield LinkInfo(
                element=element, tag=element.tag, attrib='codebase',
                link=base_link,
                inline=True, linked=False,
                base_link=None,
                value_type='plain',
                link_type=link_type
            )

        for attribute in ('code', 'src', 'classid', 'data'):
            if attribute in element.attrib:
                link_type = identify_link_type(element.attrib.get(attribute))
                yield LinkInfo(
                    element=element, tag=element.tag, attrib=attribute,
                    link=element.attrib.get(attribute),
                    inline=True, linked=False,
                    base_link=base_link,
                    value_type='plain',
                    link_type=link_type
                )

        if 'archive' in element.attrib:
            for match in re.finditer(r'[^ ]+', element.attrib.get('archive')):
                value = match.group(0)
                link_type = identify_link_type(value)
                yield LinkInfo(
                    element=element, tag=element.tag, attrib='archive',
                    link=value,
                    inline=True, linked=False,
                    base_link=base_link,
                    value_type='list',
                    link_type=link_type
                )
796262
public CarbonReply send(Element element) throws CarbonException
	{
		try
		{
			final String responseXml = send(serialise(element));

			return new CarbonReply(deserialise(responseXml));
		}
		catch (CarbonException e)
		{
			throw e;
		}
		catch (Exception e)
		{
			throw new CarbonException(e);
		}
	}
834211
public ISynchronizationPoint<Exception> searchElement(String elementName) {
		ISynchronizationPoint<Exception> next = next();
		do {
			if (!next.isUnblocked()) break;
			if (next.hasError()) return next;
			if (Type.START_ELEMENT.equals(event.type) && event.text.equals(elementName)) return next;
			next = next();
		} while (true);
		SynchronizationPoint<Exception> result = new SynchronizationPoint<>();
		ISynchronizationPoint<Exception> n = next;
		next.listenInline(() -> {
			if (n.hasError()) result.error(n.getError());
			else if (Type.START_ELEMENT.equals(event.type) && event.text.equals(elementName)) result.unblock();
			else new ParsingTask(() -> { searchElement(elementName).listenInline(result); }).start();
		}, result);
		return result;
	}
765176
public static Map<String, String> retrieveOverwriteElements(Element element) {
        Map<String, String> overwrites = new HashMap<String, String>();
        NodeList elementsByTagName = element.getElementsByTagNameNS("*", "overwrite");
        for (int i = 0; i < elementsByTagName.getLength(); i++) {
            Element overwrite = (Element) elementsByTagName.item(i);
            String originalBeanId = overwrite.getAttribute("originalBeanId");
            String newBeanId = overwrite.getAttribute("newBeanId");
            overwrites.put(originalBeanId, newBeanId);
        }
        return overwrites;
    }
660666
def serialise(self, element: Element, **kwargs) -> str:
        

        return json.dumps(self.serialise_dict(element), **kwargs)
287810
def references_by_element(self, element_href):
        
        result = self.make_request(
            method='create',
            resource='references_by_element',
            json={
                'value': element_href})
        return result
900632
def _xml_convert(self, element):
        

        children = list(element)

        if len(children) == 0:
            return self._type_convert(element.text)
        else:
            # if the fist child tag is list-item means all children are list-item
            if children[0].tag == "list-item":
                data = []
                for child in children:
                    data.append(self._xml_convert(child))
            else:
                data = {}
                for child in children:
                    data[child.tag] = self._xml_convert(child)

            return data