

def include(elem, loader=None):
    if (loader is None):
        loader = default_loader
    i = 0
    while (i < len(elem)):
        e = elem[i]
        if (e.tag == XINCLUDE_INCLUDE):
            href = e.get('href')
            parse = e.get('parse', 'xml')
            if (parse == 'xml'):
                node = loader(href, parse)
                if (node is None):
                    raise FatalIncludeError(('cannot load %r as %r' % (href, parse)))
                node = copy.copy(node)
                if e.tail:
                    node.tail = ((node.tail or '') + e.tail)
                elem[i] = node
            elif (parse == 'text'):
                text = loader(node, parse, e.get('encoding'))
                if (text is None):
                    raise FatalIncludeError(('cannot load %r as %r' % (href, parse)))
                if i:
                    node = elem[(i - 1)]
                    node.tail = (((node.tail or '') + text) + (e.tail or ''))
                else:
                    elem.text = (((elem.text or '') + text) + (e.tail or ''))
                del elem[i]
                continue
            else:
                raise FatalIncludeError(('unknown parse type in xi:include tag (%r)' % parse))
        elif (e.tag == XINCLUDE_FALLBACK):
            raise FatalIncludeError(('xi:fallback tag must be child of xi:include (%r)' % e.tag))
        else:
            include(e, loader)
        i = (i + 1)

dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/xml/etree/ElementInclude.py include/VarMisuse@180/220 `href`->`node`