org.python.core.PyInstance Java Examples
The following examples show how to use
org.python.core.PyInstance.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PythonStreamExecutionEnvironment.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static void registerJythonSerializers(StreamExecutionEnvironment env) { env.registerTypeWithKryoSerializer(PyBoolean.class, PyBooleanSerializer.class); env.registerTypeWithKryoSerializer(PyFloat.class, PyFloatSerializer.class); env.registerTypeWithKryoSerializer(PyInteger.class, PyIntegerSerializer.class); env.registerTypeWithKryoSerializer(PyLong.class, PyLongSerializer.class); env.registerTypeWithKryoSerializer(PyString.class, PyStringSerializer.class); env.registerTypeWithKryoSerializer(PyUnicode.class, PyObjectSerializer.class); env.registerTypeWithKryoSerializer(PyTuple.class, PyObjectSerializer.class); env.registerTypeWithKryoSerializer(PyObjectDerived.class, PyObjectSerializer.class); env.registerTypeWithKryoSerializer(PyInstance.class, PyObjectSerializer.class); }
Example #2
Source File: PythonCodeCompletionFactory.java From ghidra with Apache License 2.0 | 5 votes |
/** * Creates a new CodeCompletion from the given Python objects. * * @param description description of the new CodeCompletion * @param insertion what will be inserted to make the code complete * @param pyObj a Python Object * @return A new CodeCompletion from the given Python objects. */ public static CodeCompletion newCodeCompletion(String description, String insertion, PyObject pyObj) { JComponent comp = null; if (pyObj != null) { if (includeTypes) { /* append the class name to the end of the description */ String className = getSimpleName(pyObj.getClass()); if (pyObj instanceof PyInstance) { /* get the real class */ className = getSimpleName(((PyInstance) pyObj).instclass.__name__); } else if (className.startsWith("Py")) { /* strip off the "Py" */ className = className.substring("Py".length()); } description = description + " (" + className + ")"; } comp = new GDLabel(description); Iterator<Class<?>> iter = classes.iterator(); while (iter.hasNext()) { Class<?> testClass = iter.next(); if (testClass.isInstance(pyObj)) { comp.setForeground(classToColorMap.get(testClass)); break; } } } return new CodeCompletion(description, insertion, comp); }
Example #3
Source File: GameScript.java From marauroa with GNU General Public License v2.0 | 2 votes |
/** * Get Python RPWorld implementation * * @return Python RPWorld implementation * @throws Exception */ public PythonWorld getWorld() throws Exception { String pythonZoneClass = conf.get("python_script_world"); PyInstance object = (PyInstance) interpreter.eval(pythonZoneClass + "()"); return (PythonWorld) object.__tojava__(PythonWorld.class); }
Example #4
Source File: GameScript.java From marauroa with GNU General Public License v2.0 | 2 votes |
/** * Get the Python IRPRuleProcessor implemenation * * @return Python IRPRuleProcessor implemenation * @throws Exception */ public PythonRP getGameRules() throws Exception { String pythonRPClass = conf.get("python_script_ruleprocessor"); PyInstance object = (PyInstance) interpreter.eval(pythonRPClass + "(gamescript__world)"); return (PythonRP) object.__tojava__(PythonRP.class); }