Package org.python.core

Examples of org.python.core.PyObject


                    Object loader = 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__");
                            loader = dict.__finditem__("__loader__");
                        } // else built-in
                    }   // else some system module?

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


   * the referenced python module into Java bytecode
   */

  public InterpreterType create(String scripts) {

    PyObject buildingObject = interpreterClass.__call__(new PyString(
        scripts));
    InterpreterType ele = (InterpreterType) buildingObject
        .__tojava__(InterpreterType.class);
    return ele;
  }
View Full Code Here

      Row row = node.getBelongsToRow();

      interpreter.set("nodeid", node.getId());

      try {
        PyObject output = interpreter.eval(py);
        String transformedValue = PythonTransformationHelper
            .getPyObjectValueAsString(output);
        addTransformedValue(transformedRows, row, transformedValue);
      } catch (PyException p) {
        logger.info("error in evaluation python, skipping one row");
View Full Code Here

    evalColumns.clear();
    try {
      ArrayList<Node> nodes = new ArrayList<Node>(r.getNodes());
      Node node = nodes.get(0);
      interpreter.set("nodeid", node.getId());
      PyObject output = interpreter.eval(code);
      return PythonTransformationHelper.getPyObjectValueAsBoolean(output);
    }catch(Exception e) {
      return onError;
    }
View Full Code Here

    */
   public RobotStep getNextStep()
   {
      try
      {
         final PyObject function = this.currentInterpreter.get("nextStep");
         Object result = function.__call__();
         return RobotStep.valueOf(result.toString());
      }
      catch (Exception ex)
      {
         ex.printStackTrace();
View Full Code Here

   }

   private String getVariableType(String variableName)
   {
      final PythonInterpreter interp = this.getCurrentInterpreter();
      PyObject selectedObj = interp.get(variableName);
      if (selectedObj != null)

         return selectedObj.getType().toString();
      else
         return "Unknown";
   }
View Full Code Here

   }

   private String getVariableValue(String variableName)
   {
      final PythonInterpreter interp = this.getCurrentInterpreter();
      PyObject selectedObj = interp.get(variableName);
      if (selectedObj != null)

         return selectedObj.toString();
      else
         return "Unknown";
   }
View Full Code Here

   private void updateMethodsList(String selectedToken)
   {
      try
      {
         final PythonInterpreter interp = this.getCurrentInterpreter();
         PyObject obj = interp.eval("dir(" + selectedToken + ")");
         PyList pyList = (PyList) obj;
         final ScriptInfoPanel info = ScriptInfoPanel.getInstance();
         info.getListModel().clear();
         for (Object o : pyList)
         {
View Full Code Here

                if (!key.startsWith("__") && !key.equals("schemaFunction")
                        && !key.equals("outputSchema")
                        && !key.equals("outputSchemaFunction")
                        && (value instanceof PyFunction)
                        && (((PyFunction)value).__findattr__("schemaFunction")== null)) {
                    PyObject obj = ((PyFunction)value).__findattr__("outputSchema");
                    if(obj != null) {
                        Utils.getSchemaFromString(obj.toString());
                    }
                    funcspec = new FuncSpec(JythonFunction.class.getCanonicalName() + "('"
                            + path + "','" + key +"')");
                    pigContext.registerFunction(namespace + key, funcspec);
                    LOG.info("Register scripting UDF: " + namespace + key);
View Full Code Here

                        }
                    }
                }
            } catch (PyException e) {
                if (e.match(Py.SystemExit)) {
                    PyObject value = e.value;
                    if (PyException.isExceptionInstance(e.value)) {
                        value = value.__findattr__("code");
                    }
                    if (new  PyInteger(0).equals(value)) {
                        LOG.info("Script invoked sys.exit(0)");
                        return;
                    }
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.