throw new RuntimeException(
Services.getMessage("python.missing.nature"));
}
IInterpreterInfo interpreter = null;
IInterpreterManager manager = nature.getRelatedInterpreterManager();
IInterpreterInfo[] existing = manager.getInterpreterInfos();
for (IInterpreterInfo info : existing){
if (info.getName().equals(interpreterNameOrPath) ||
info.getExecutableOrJar().equals(interpreterNameOrPath))
{
interpreter = info;
break;
}
}
File path = new File(interpreterNameOrPath);
if (interpreter == null && path.exists() && path.isFile()){
HashSet<String> skip = new HashSet<String>();
for (IInterpreterInfo info : existing){
skip.add(info.getExecutableOrJar());
}
interpreter = manager.createInterpreterInfo(
interpreterNameOrPath, new NullProgressMonitor(), false);
interpreter.setName(FileUtils.getBaseName(interpreterNameOrPath));
IInterpreterInfo[] updated = new IInterpreterInfo[existing.length + 1];
System.arraycopy(existing, 0, updated, 0, existing.length);
updated[updated.length - 1] = interpreter;
manager.setInfos(updated, skip, new NullProgressMonitor());
}else if (interpreter == null){
throw new RuntimeException(Services.getMessage(
"python.interpreter.not.found", interpreterNameOrPath));
}