org.python.util.PythonInterpreter.initialize()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(294)

本文整理了Java中org.python.util.PythonInterpreter.initialize()方法的一些代码示例,展示了PythonInterpreter.initialize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。PythonInterpreter.initialize()方法的具体详情如下:
包路径:org.python.util.PythonInterpreter
类名称:PythonInterpreter
方法名:initialize

PythonInterpreter.initialize介绍

[英]Initializes the Jython runtime. This should only be called once, before any other Python objects (including PythonInterpreter) are created.
[中]初始化Jython运行时。在创建任何其他Python对象(包括PythonInterpreter)之前,应该只调用一次。

代码示例

代码示例来源:origin: spring-projects/spring-security

public PythonInterpreterPrePostInvocationAttributeFactory() {
  PythonInterpreter.initialize(System.getProperties(), null, new String[] {});
}

代码示例来源:origin: org.geoserver.script/gs-script-py

@Override
public void init(ScriptManager scriptMgr) throws Exception {
  // add lib to python.path
  Properties props = new Properties();
  props.put("python.path", scriptMgr.script("lib/" + "py").dir().getAbsolutePath());
  PythonInterpreter.initialize(null, props, null);
  //        codecs.register(new PyObject() {
  //            @Override
  //            public PyObject __call__(PyObject arg0) {
  //                if ("idna".equals(arg0.toString())) {
  //                    return new PyTuple(
  //                        new PyObject() {
  //                            public PyObject __call__(PyObject v) {
  //                                return new PyTuple(new
  // PyString(IDN.toUnicode(v.toString())), new PyInteger(0));
  //                            }
  //                        },
  //                        new PyObject() {
  //                            public PyObject __call__(PyObject v) {
  //                                return new PyTuple(new
  // PyString(IDN.toASCII(v.toString())), new PyInteger(0));
  //                            }
  //                        }
  //                    );
  //                }
  //                return Py.None;
  //            }
  //        });
}

代码示例来源:origin: org.python/jython

/**
 * Motivated by a NPE reported on http://bugs.jython.org/issue1174.
 */
public void testBasicEval() throws Exception {
  PyDictionary test = new PyDictionary();
  test.__setitem__(new PyUnicode("one"), new PyUnicode("two"));
  PythonInterpreter.initialize(System.getProperties(), null, new String[] {});
  PythonInterpreter interp = new PythonInterpreter();
  PyObject pyo = interp.eval("{u'one': u'two'}");
  assertEquals(test, pyo);
}

代码示例来源:origin: org.python/jython

PythonInterpreter.initialize(System.getProperties(), props, new String[0]);
PySystemState systemState = new PySystemState();
interp = new PythonInterpreter(null, systemState);

相关文章