package com.jetbrains.python.sdk;

import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;

import java.io.File;
import java.util.Collection;

/**
 * @author yole
 */
public class JythonSdkFlavor extends PythonSdkFlavor {
  private JythonSdkFlavor() {
  }

  public static JythonSdkFlavor INSTANCE = new JythonSdkFlavor();

  @Override
  public boolean isValidSdkHome(String path) {
    File file = new File(path);
    return file.isFile() && FileUtil.getNameWithoutExtension(file).toLowerCase().startsWith("jython");
  }

  @Override
  public String getVersionString(String sdkHome) {
    return getVersionFromOutput(sdkHome, "--version", "(Jython \\S+) on .*", false);
  }

  @Override
  public void initPythonPath(GeneralCommandLine cmd, Collection<String> path) {
    cmd.getParametersList().add(getPythonPathCmdLineArgument(path));
  }

  public static String getPythonPathCmdLineArgument(Collection<String> path) {
    return "-Dpython.path=" + StringUtil.join(path, File.pathSeparator);
  }
}

@@ -862,24 +862,100 @@
 ng%3E path) %7B%0A
+    addToEnv(cmd, %22JYTHONPATH%22, StringUtil.join(path, File.pathSeparator));%0A
     cmd.getP

set JYTHONPATH to the same string as -Dpython.path (for better compat with Jython 2.5) (PY-3249)