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


Java PythonNature.setVersion方法代码示例

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


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

示例1: doIt

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
private boolean doIt() {
    IProject project = getProject();

    if (project != null) {
        PythonNature pythonNature = PythonNature.getPythonNature(project);

        try {
            String projectInterpreter = projectConfig.getProjectInterpreter();
            if (projectInterpreter == null) {
                return false;
            }
            pythonNature.setVersion(projectConfig.getSelectedPythonOrJythonAndGrammarVersion(), projectInterpreter);
        } catch (CoreException e) {
            Log.log(e);
        }
    }
    return true;
}
 
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:19,代码来源:PyProjectPythonDetails.java

示例2: doIt

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
private boolean doIt() {
    IProject project = getProject();

    if (project != null) {
        PythonNature pythonNature = PythonNature.getPythonNature(project);

        try {
            String projectInterpreter = projectConfig.getProjectInterpreter();
            if (projectInterpreter == null) {
                return false;
            }
            pythonNature.setVersion(projectConfig.getSelectedPythonOrJythonAndGrammarVersion(), projectInterpreter);
            pythonNature.setAdditionalGrammarValidation(projectConfig.getAdditionalGrammarValidation());
        } catch (CoreException e) {
            Log.log(e);
        }
    }
    //re-enable "configure interpreter" dialogs
    PyDialogHelpers.enableAskInterpreterStep(true);
    return true;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:22,代码来源:PyProjectPythonDetails.java

示例3: testPythonCommandLine

import org.python.pydev.plugin.nature.PythonNature; //导入方法依赖的package包/类
public void testPythonCommandLine() throws Exception {
    PythonNature nature = PythonNature.getPythonNature(mod1);

    // Create a temporary variable for testing
    IStringVariableManager variableManager = VariablesPlugin.getDefault().getStringVariableManager();
    IValueVariable myCustomVariable = variableManager.newValueVariable("pydev_python_runner_config_test_var", "",
            true, "my_custom_value");
    variableManager.addVariables(new IValueVariable[] { myCustomVariable });

    try {
        IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager(true);
        InterpreterInfo info = (InterpreterInfo) manager.getDefaultInterpreterInfo(false);
        info.setEnvVariables(new String[] { "MY_CUSTOM_VAR_FOR_TEST=FOO", "MY_CUSTOM_VAR_FOR_TEST2=FOO2",
                "MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}" });

        // Make sure variable hasn't been expanded too early
        assertTrue(arrayContains(info.getEnvVariables(),
                "MY_CUSTOM_VAR_WITH_VAR=${pydev_python_runner_config_test_var}"));

        PythonRunnerConfig runnerConfig = createConfig();
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=FOO2"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value"));

        String[] argv = runnerConfig.getCommandLine(false);
        assertFalse(arrayContains(argv, PythonRunnerConfig.getRunFilesScript()));
        assertTrue(arrayContains(argv, mod1.getLocation().toOSString()));

        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
        assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), nature.getProjectInterpreter()
                .getExecutableOrJar());
        runnerConfig = createConfig();
        argv = runnerConfig.getCommandLine(false);
        assertEquals(manager.getDefaultInterpreterInfo(false).getExecutableOrJar(), argv[0]);

        IInterpreterManager interpreterManager = nature.getRelatedInterpreterManager();

        InterpreterInfo info2 = new InterpreterInfo(IPythonNature.PYTHON_VERSION_2_6, "c:\\interpreter\\py25.exe",
                new ArrayList<String>());
        interpreterManager.setInfos(new IInterpreterInfo[] { info, info2 }, null, null);

        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, "c:\\interpreter\\py25.exe");
        assertEquals("c:\\interpreter\\py25.exe", nature.getProjectInterpreter().getExecutableOrJar());
        runnerConfig = createConfig();
        argv = runnerConfig.getCommandLine(false);
        assertEquals("c:\\interpreter\\py25.exe", argv[0]);
        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);

        ILaunchConfiguration config;
        config = new LaunchShortcut().createDefaultLaunchConfiguration(FileOrResource
                .createArray(new IResource[] { mod1 }));
        ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("VAR_SPECIFIED_IN_LAUNCH", "BAR");
        map.put("MY_CUSTOM_VAR_FOR_TEST2", "BAR2"); //The one in the launch configuration always has preference.
        workingCopy.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, map);
        config = workingCopy.doSave();

        runnerConfig = new PythonRunnerConfig(config, ILaunchManager.RUN_MODE, PythonRunnerConfig.RUN_REGULAR);
        assertTrue(arrayContains(runnerConfig.envp, "VAR_SPECIFIED_IN_LAUNCH=BAR"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST=FOO"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_FOR_TEST2=BAR2"));
        assertTrue(arrayContains(runnerConfig.envp, "MY_CUSTOM_VAR_WITH_VAR=my_custom_value"));
    } catch (Throwable e) {
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        //restore the default!
        nature.setVersion(IPythonNature.Versions.PYTHON_VERSION_LATEST, IPythonNature.DEFAULT_INTERPRETER);
        variableManager.removeVariables(new IValueVariable[] { myCustomVariable });
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:73,代码来源:PythonRunnerConfigTestWorkbench.java


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