Examples of PyFunction


Examples of org.python.core.PyFunction

    public List<String> getParameterNames(String name) {
        PyObject obj = function(name);
        PythonInterpreter pi = py.interpreter();
        pi.exec("from inspect import getargspec");
       
        PyFunction getargspec = (PyFunction) pi.get("getargspec");
        PySequence argspec =
            (PySequence) getargspec.__call__(obj.__getattr__("wrapped")).__getitem__(0);
       
        List<String> list = new ArrayList();
        int i = 0;
        for (Object item : (Collection) argspec) {
            //skip first argument because that is what gets evaluated by
View Full Code Here

Examples of org.python.core.PyFunction

    PyFunction findDecoratedFunction(ScriptEngine engine, String name) {
        Bindings bindings = engine.getBindings(ScriptContext.ENGINE_SCOPE);
        for (Object o : bindings.values()) {
            if (o instanceof PyFunction) {
                PyFunction f = (PyFunction) o;
                PyObject d = f.__findattr__("__decorator__");
                if (d instanceof PyFunction && name.equals(((PyFunction)d).__name__)) {
                    return f;
                }
            }
        }
View Full Code Here

Examples of org.python.core.PyFunction

        }
        return null;
    }

    boolean findAndCall(String name, ScriptEngine engine, Object... args) {
        PyFunction f = findDecoratedFunction(engine, name);
        if (f != null) {
            call(f, args);
            return true;
        }
        return false;
View Full Code Here

Examples of org.python.core.PyFunction

    /**
     * Creates the start_response object.
     */
    PyFunction createStartResponse() {
        return new PyFunction(new PyStringMap(), new PyObject[]{}, Py.newJavaCode(getClass(), "start_response"));
    }
View Full Code Here

Examples of org.python.core.PyFunction

    public List<String> getParameterNames(String name) {
        PyObject obj = function(name);
        PythonInterpreter pi = py.interpreter();
        pi.exec("from inspect import getargspec");
       
        PyFunction getargspec = (PyFunction) pi.get("getargspec");
        PySequence argspec =
            (PySequence) getargspec.__call__(obj.__getattr__("wrapped")).__getitem__(0);
       
        List<String> list = new ArrayList();
        int i = 0;
        for (Object item : (Collection) argspec) {
            //skip first argument because that is what gets evaluated by
View Full Code Here

Examples of org.python.core.PyFunction

        PyType type = type();
       
        PythonInterpreter pi = py.interpreter();
        pi.exec("from inspect import getargspec");
       
        PyFunction getargspec = (PyFunction) pi.get("getargspec");
        PyObject init =  type.__getattr__("__init__");
       
        PySequence argspec =
            (PySequence) getargspec.__call__(init.__getattr__("wrapped")).__getitem__(0);
        PyDictionary params = (PyDictionary) init.__getattr__("params");
       
        List<Param> list = new ArrayList();
        for (Object item : (Collection) argspec) {
            String pname = item.toString();
View Full Code Here

Examples of org.python.core.PyFunction

        }
        return null;
    }
   
    PyFunction createStartResponse() {
        return new PyFunction(new PyStringMap(), new PyObject[]{}, Py.newJavaCode(getClass(), "start_response"));
    }
View Full Code Here

Examples of org.python.core.PyFunction

        }
        if (!(app instanceof PyFunction)) {
            throw new RestletException("'app' must be a function", Status.SERVER_ERROR_INTERNAL);
        }
       
        PyFunction appf = (PyFunction) app;
        PyFunction start_response = createStartResponse();
       
        WSGIResponse wr = new WSGIResponse();
        response.set(wr);
       
        PyObject ret = appf.__call__(new PyObject[]{createEnviron(getRequest()), start_response });
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.