当前位置: 首页>>代码示例>>Java>>正文


Java PyList.add方法代码示例

本文整理汇总了Java中org.python.core.PyList.add方法的典型用法代码示例。如果您正苦于以下问题:Java PyList.add方法的具体用法?Java PyList.add怎么用?Java PyList.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.python.core.PyList的用法示例。


在下文中一共展示了PyList.add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addToPythonPath

import org.python.core.PyList; //导入方法依赖的package包/类
/** @param path Path to add to head of python search path */
private void addToPythonPath(final String path)
{
    // Since using default PySystemState (see above), check if already in paths
    final PyList paths = python.getSystemState().path;

    // Prevent concurrent modification
    synchronized (JythonScriptSupport.class)
    {
        final int index = paths.indexOf(path);
        // Already top entry?
        if (index == 0)
            return;
        // Remove if further down in the list
        if (index > 0)
            paths.remove(index);
        // Add to front of list
        paths.add(0, path);
    }
    logger.log(Level.FINE, "Adding to jython path: {0}", path);
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:22,代码来源:JythonScriptSupport.java

示例2: pigToPython

import org.python.core.PyList; //导入方法依赖的package包/类
public static PyObject pigToPython(Object object) {
    if (object instanceof Tuple) {
        return pigTupleToPyTuple((Tuple) object);
    } else if (object instanceof DataBag) {
        PyList list = new PyList();
        for (Tuple bagTuple : (DataBag) object) {
            list.add(pigTupleToPyTuple(bagTuple));
        }
        return list;
    } else if (object instanceof Map<?, ?>) {
        PyDictionary newMap = new PyDictionary();
        for (Map.Entry<?, ?> entry : ((Map<?, ?>) object).entrySet()) {
            newMap.put(entry.getKey(), pigToPython(entry.getValue()));
        }
        return newMap;
    } else if (object instanceof DataByteArray) {
        return Py.java2py(((DataByteArray) object).get());
    } else {
        return Py.java2py(object);
    }
}
 
开发者ID:sigmoidanalytics,项目名称:spork-streaming,代码行数:22,代码来源:JythonUtils.java

示例3: runCxxTestGen

import org.python.core.PyList; //导入方法依赖的package包/类
private void runCxxTestGen( String testTarget, List<String> arguments ) throws MojoExecutionException
{
    final String cxxTestGenArgVar = "cxxTestGenArgs";
    
    String cxxTestGenPath = cxxTest.getCxxTestHome().getAbsolutePath();
    PyList cxxTestGenArgs = new PyList( arguments );
    cxxTestGenArgs.add( 0, cxxTestGenPath );
    
    getLog().info( "Executing test runner generation for target " + testTarget + "." );
    getLog().debug( "Executing Python script " + cxxTestGenPath + " with arguments=" + cxxTestGenArgs );

    PythonInterpreter pythonInterpreter = new PythonInterpreter();
    pythonInterpreter.exec( "import cxxtest" );
    resetCxxTestSuites( pythonInterpreter );
    
    pythonInterpreter.set( cxxTestGenArgVar, cxxTestGenArgs );
    pythonInterpreter.exec( "cxxtest.main(" + cxxTestGenArgVar + ")" );  
    pythonInterpreter.cleanup();
    
    getLog().info( "Test runner generation for target " + testTarget + " succeeded." );
}
 
开发者ID:andi12,项目名称:msbuild-maven-plugin,代码行数:22,代码来源:CxxTestGenMojo.java

示例4: initialise

import org.python.core.PyList; //导入方法依赖的package包/类
private final void initialise()
{
	this.classes = new HashMap<ClassName, PyObject>();

	// Create a Python Interpreter with its own "path", and its own namespace
	// This ensures that one instance does not interfere with another, so
	// you can run one Game, then another without any name clashes.
	
    PySystemState systemState = new PySystemState();
    PyList pathList = new PyList();
    pathList.add( this.manager.getScriptDirectory().getPath() );
    pathList.add( this.manager.getIncludeDirectory(this).getPath() );
    systemState.path = pathList;

    PyDictionary namespace = new PyDictionary();
    this.interpreter = new PythonInterpreter( namespace, systemState );
}
 
开发者ID:nickthecoder,项目名称:itchy,代码行数:18,代码来源:PythonLanguage.java

示例5: createArray

import org.python.core.PyList; //导入方法依赖的package包/类
@Override
public Object createArray(List elements) {
  PyList list = new PyList();
  for (Object element : elements) {
    list.add(element);
  }
  return list;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:9,代码来源:JythonProcessor.java

示例6: init

import org.python.core.PyList; //导入方法依赖的package包/类
/** Perform static, one-time initialization */
private static boolean init()
{
    try
    {
        final Properties pre_props = System.getProperties();
        final Properties props = new Properties();

        // Locate the jython plugin for 'home' to allow use of /Lib in there
        final String home = getPluginPath("org.python.jython", "/");
        if (home == null)
            throw new Exception("Cannot locate jython bundle. No OSGi?");

        // Jython 2.7(b3) needs these to set sys.prefix and sys.executable.
        // If left undefined, initialization of Lib/site.py fails with
        // posixpath.py", line 394, in normpath AttributeError:
        // 'NoneType' object has no attribute 'startswith'
        props.setProperty("python.home", home);
        props.setProperty("python.executable", "None");

        // Disable cachedir to avoid creation of cachedir folder.
        // See http://www.jython.org/jythonbook/en/1.0/ModulesPackages.html#java-package-scanning
        // and http://wiki.python.org/jython/PackageScanning
        props.setProperty(PySystemState.PYTHON_CACHEDIR_SKIP, "true");

        // With python.home defined, there is no more
        // "ImportError: Cannot import site module and its dependencies: No module named site"
        // Skipping the site import still results in faster startup
        props.setProperty("python.import.site", "false");

        // Prevent: console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.
        props.setProperty("python.console.encoding", "UTF-8");

        // This will replace entries found on JYTHONPATH
        final String python_path = Preferences.getPythonPath();
        if (! python_path.isEmpty())
            props.setProperty("python.path", python_path);

        // Options: error, warning, message (default), comment, debug
        // props.setProperty("python.verbose", "debug");
        // Options.verbose = Py.DEBUG;

        PythonInterpreter.initialize(pre_props, props, new String[0]);

        final PyList paths = Py.getSystemState().path;
        paths.add(getPluginPath("org.csstudio.display.builder.runtime", "scripts"));

        return true;
    }
    catch (Exception ex)
    {
        logger.log(Level.SEVERE, "Once this worked OK, but now the Jython initialization failed. Don't you hate computers?", ex);
    }
    return false;
}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:56,代码来源:JythonScriptSupport.java


注:本文中的org.python.core.PyList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。