Package org.python.core

Examples of org.python.core.PyObject


     */
    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

                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

    public boolean isAllowed( Tuple tuple ) throws ConditionException
    {
        try
        {

            PyObject result = __builtin__.eval( getCode( ),
                                                setUpDictionary( tuple, declarationIterator( )  ),
                                                getGlobals( ) );

            Object answer = result.__tojava__( Object.class );

            if ( !( answer instanceof Number ) )
            {
                throw new NonBooleanExprException( getText( ) );
            }
View Full Code Here

    public PyDictionary getGlobals(String text)
    {
        PyModule module = new PyModule( "main",
                                        new PyDictionary( ) );

        PyObject locals = module.__dict__;      

        Py.exec( Py.compile_flags( text,
                                   "<string>",
                                   "exec",
                                   null ),
View Full Code Here

    /**
     * Creates and returns an instance of the robot.JarRunner (implemented in
     * Python), which can be used to execute tests.
     */
    public RobotRunner createRunner() {
        PyObject runnerObject = runnerClass.__call__();
        return (RobotRunner) runnerObject.__tojava__(RobotRunner.class);
    }
View Full Code Here

        try {
            f = JythonScriptEngine.getFunction(filename, functionName);
            this.function = f;
            num_parameters = ((PyBaseCode) f.func_code).co_argcount;
            PyObject outputSchemaDef = f.__findattr__("outputSchema".intern());
            if (outputSchemaDef != null) {
                this.schema = Utils.getSchemaFromString(outputSchemaDef.toString());
                found = true;
            }
            PyObject outputSchemaFunctionDef = f.__findattr__("outputSchemaFunction".intern());
            if (outputSchemaFunctionDef != null) {
                if(found) {
                    throw new ExecException(
                            "multiple decorators for " + functionName);
                }
                scriptFilePath = filename;
                outputSchemaFunc = outputSchemaFunctionDef.toString();
                this.schema = null;
                found = true;
            }
            PyObject schemaFunctionDef = f.__findattr__("schemaFunction".intern());
            if (schemaFunctionDef != null) {
                if(found) {
                    throw new ExecException(
                            "multiple decorators for " + functionName);
                }
View Full Code Here

    @Override
    public Object exec(Tuple tuple) throws IOException {
        try {
            if (tuple == null || num_parameters == 0) {
                // ignore input tuple
                PyObject out = function.__call__();
                return JythonUtils.pythonToPig(out);
            }
            else {
                // this way we get the elements of the tuple as parameters instead
                // of one tuple object
View Full Code Here

            if(outputSchemaFunc != null) {
                PyFunction pf;
                try {
                    pf = JythonScriptEngine.getFunction(scriptFilePath, outputSchemaFunc);
                    // this should be a schema function
                    PyObject schemaFunctionDef = pf.__findattr__("schemaFunction".intern());
                    if(schemaFunctionDef == null) {
                        throw new IllegalStateException("Function: "
                                + outputSchemaFunc + " is not a schema function");
                    }
                    return (Schema)((pf.__call__(Py.java2py(input))).__tojava__(Object.class));
View Full Code Here

                if (!key.startsWith("__") && !key.equals("schemaFunction")
                        && !key.equals("outputSchema")
                        && !key.equals("outputSchemaFunction")
                        && (value instanceof PyFunction)
                        && (((PyFunction)value).__findattr__("schemaFunction".intern())== null)) {
                    PyObject obj = ((PyFunction)value).__findattr__("outputSchema".intern());
                    if(obj != null) {
                        Utils.getSchemaFromString(obj.toString());
                    }
                    funcspec = new FuncSpec(JythonFunction.class.getCanonicalName() + "('"
                            + path + "','" + key +"')");
                    pigContext.registerFunction(namespace + key, funcspec);
                }
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.