Examples of PyModule


Examples of jep.python.PyModule

     * @param name a <code>String</code> value
     * @return a <code>PyModule</code> value
     * @exception JepException if an error occurs
     */
    public PyModule createModule(String name) throws JepException {
        return (PyModule) trackObject(new PyModule(
                                          this.tstate,
                                          createModule(this.tstate,
                                                       name),
                                          this));
    }
View Full Code Here

Examples of jep.python.PyModule

     * @param name a <code>String</code> value
     * @return an <code>Object</code> value
     */
    public Object get(String name) {
        try {
            PyModule module = null;
            String[] tokens = null;

            if(name.indexOf('.') > 0) {
                // split package name by '.' and make modules
                tokens = name.split("\\.");
                for(int i = 0; i < tokens.length - 1; i++) {
                    if(module == null)
                        module = jep.createModule(tokens[i]);
                    else
                        module = module.createModule(tokens[i]);
                }
            }

            if(module == null)
                return this.jep.getValue(name);
            else
                return module.getValue(tokens[tokens.length - 1]);
        }
        catch(JepException e) {
            // probably not found. javax.script wants use to just return null
            return null;
        }
View Full Code Here

Examples of jep.python.PyModule

     * @exception IllegalArgumentException if an error occurs
     */
    public void put(String name,
            Object val) throws IllegalArgumentException {
        try {
            PyModule module = null;
            String[] tokens = null;
            String   mname  = null;

            if(name.indexOf('.') > 0) {
                // split package name by '.' and make modules
                tokens = name.split("\\.");
                for(int i = 0; i < tokens.length - 1; i++) {
                    mname = tokens[i];
                    if(module == null)
                        module = jep.createModule(mname);
                    else
                        module = module.createModule(mname);
                }
            }

            if(module == null)
                this.jep.set(name, val);
            else
                module.set(tokens[tokens.length - 1], val);
        }
        catch(JepException e) {
            throw new IllegalArgumentException(e);
        }
    }
View Full Code Here

Examples of org.python.core.PyModule

     * @param text
     * @return PyDictionary globals
     */
    public PyDictionary getGlobals(String text)
    {
        PyModule module = new PyModule( "main",
                                        new PyDictionary( ) );

        PyObject locals = module.__dict__;      

        Py.exec( Py.compile_flags( text,
View Full Code Here

Examples of org.python.core.PyModule

        } catch (Exception e) {
            interp = new InteractiveConsole();
        }

        //System.err.println("interp");
        PyModule mod = imp.addModule("__main__");
        interp.setLocals(mod.__dict__);
        //System.err.println("imp");

        for (int i = 0; i < opts.warnoptions.size(); i++) {
            String wopt = (String) opts.warnoptions.elementAt(i);
View Full Code Here

Examples of org.python.core.PyModule

                    } catch (IOException e) {
                        throw Py.IOError(e);
                    }
                    break;
                case PKG_DIRECTORY:
                    PyModule m = org.python.core.imp.addModule(name);
                    m.__dict__.__setitem__("__path__", new PyList(new PyObject[] { filename }));
                    m.__dict__.__setitem__("__file__", filename);
                    ModuleInfo mi = findFromSource(name, filename, true);
                    type = mi.type;
                    file = mi.file;
View Full Code Here

Examples of org.python.core.PyModule

                        new PyTuple(new PyObject[] { new PyString(".class"), new PyString("rb"),
                                Py.newInteger(PY_COMPILED), }), });
    }

    public static PyModule new_module(String name) {
        return new PyModule(name, null);
    }
View Full Code Here

Examples of org.python.core.PyModule

        setSystemState();

        if (useThreadLocalState) {
            threadLocals = new ThreadLocal<PyObject>();
        } else {
            PyModule module = new PyModule("__main__", dict);
            systemState.modules.__setitem__("__main__", module);
        }
    }
View Full Code Here

Examples of org.python.core.PyModule

        // XXX: Hack for JPython 1.0.1. By default __builtin__ is not in
        // sys.modules.
        imp.importName("__builtin__", true);

        PyModule copyreg = (PyModule)importModule("copy_reg");

        dispatch_table = (PyDictionary)copyreg.__getattr__("dispatch_table");
        extension_registry = (PyDictionary)copyreg.__getattr__("_extension_registry");
        inverted_registry = (PyDictionary)copyreg.__getattr__("_inverted_registry");

        PickleError = Py.makeClass("PickleError", Py.Exception, _PickleError());
        PicklingError = Py.makeClass("PicklingError", PickleError, exceptionNamespace());
        UnpickleableError = Py.makeClass("UnpickleableError", PicklingError, _UnpickleableError());
        UnpicklingError = Py.makeClass("UnpicklingError", PickleError, exceptionNamespace());
View Full Code Here

Examples of org.python.core.PyModule

                    break;
                case PY_COMPILED:
                    mod = load_compiled(name, filename.toString(), file);
                    break;
                case PKG_DIRECTORY:
                    PyModule m = org.python.core.imp.addModule(name);
                    m.__dict__.__setitem__("__path__", new PyList(new PyObject[] {filename}));
                    m.__dict__.__setitem__("__file__", filename);
                    ModuleInfo mi = findFromSource(name, filename.toString(), true, true);
                    type = mi.type;
                    file = mi.file;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.