

def ajax_import(url, namespace=None, names=None):
    setCompilerOptions('noDebug')
    if __imported__.has_key(url):
        module = __imported__[url]
    else:
        req = load(url, None, None, False)
        module = None
        name_getter = []
        if (names is None):
            names = []
        for name in names:
            name_getter.append(("$pyjs$moduleObject['%s'] = %s;" % (name, name)))
        script = ('(function ( ) {\n$pyjs$moduleObject={};\n%s;\n%s\nreturn $pyjs$moduleObject;\n})();' % (req.responseText, '\n'.join(name_getter)))
        try:
            module = eval(script)
        except:
            e = sys.exc_info()
            raise AjaxError(('Error in %s: %s' % (url, e.message)))
        __imported__[url] = module
    inject(module, namespace, names)

dataset/ETHPy150Open anandology/pyjamas/library/dynamic.py ajax_import/original