Package org.python.core

Examples of org.python.core.PyObject


                    Object fileEntry = null;
                    if (value instanceof PyJavaPackage ) {
                        fileEntry = ((PyJavaPackage) value).__file__;
                    } else if (value instanceof PyObject) {
                        // resolved through the filesystem (or built-in)
                        PyObject dict = ((PyObject) value).getDict();
                        if (dict != null) {
                            fileEntry = dict.__finditem__("__file__");
                        } // else built-in
                    }   // else some system module?

                    if (fileEntry != null) {
                        File file = new File(fileEntry.toString());
View Full Code Here


        return new PythonSearchScript((PyCode) compiledScript, vars, lookup);
    }

    @Override
    public Object execute(Object compiledScript, Map<String, Object> vars) {
        PyObject pyVars = Py.java2py(vars);
        interp.setLocals(pyVars);
        PyObject ret = interp.eval((PyCode) compiledScript);
        if (ret == null) {
            return null;
        }
        return ret.__tojava__(Object.class);
    }
View Full Code Here

        }

        @Override
        public Object run() {
            interp.setLocals(pyVars);
            PyObject ret = interp.eval(code);
            if (ret == null) {
                return null;
            }
            return ret.__tojava__(Object.class);
        }
View Full Code Here

        }

        @Override
        public Object run() {
            interp.setLocals(pyVars);
            PyObject ret = interp.eval(code);
            if (ret == null) {
                return null;
            }
            return ret.__tojava__(Object.class);
        }
View Full Code Here

                interpretBuffer();
            }

            private void interpretBuffer() {
                synchronized(JythonRuntime.this) {
                    PyObject prevOut = systemState.stdout;
                    try {
                        setOut(out);
                        set("env", env);
                        exec(buf.toString());
                        buf.setLength(0);
View Full Code Here

        if(key != null)
        {
            key = key.intern();
        }
       
        PyObject obj = null;
       
        try
        {
            if(wrapper.isAttributesShadowItems())
            {
View Full Code Here

     */
    public TemplateCollectionModel keys() throws TemplateModelException
    {
        try
        {
            PyObject method = object.__findattr__(KEYS);
            if(method == null)
            {
                method = object.__findattr__(KEYSET);
            }
            if(method != null)
            {
                return (TemplateCollectionModel)wrapper.wrap(method.__call__());
            }
        }
        catch(PyException e)
        {
            throw new TemplateModelException(e);
View Full Code Here

     */
    public TemplateCollectionModel values() throws TemplateModelException
    {
        try
        {
            PyObject method = object.__findattr__(VALUES);
            if(method != null)
            {
                return (TemplateCollectionModel)wrapper.wrap(method.__call__());
            }
        }
        catch(PyException e)
        {
            throw new TemplateModelException(e);
View Full Code Here

                        && !(node.getNode().toString().startsWith("'''"));
            }
        });

        if (callNodes[0] instanceof If) {
            PyObject testObject = ((If) callNodes[0]).getTest();
            if (testObject instanceof Call) {
                Call test = (Call) testObject;
                PyObject functionObject = test.getFunc();
                if (functionObject instanceof Name) {
                    Name funcName = (Name) functionObject;
                    if (funcName.getInternalId().equals("window")) {
                        expr windowNameObject = test.getInternalArgs().get(0);
                        if (windowNameObject instanceof Str) {
View Full Code Here

            return name.substring(0, name.length() - 3);
        return name;
    }

    private void defineVariable(String varname, String value) {
        PyObject builtin = interpreterEval("__builtin__");
        PyObject pyString;
        if (value == null)
            pyString = Py.None;
        else
            pyString = new PyString(value);
        builtin.__setattr__(varname, pyString);
View Full Code Here

TOP

Related Classes of org.python.core.PyObject

Copyright © 2018 www.massapicom. 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.