package com.jetbrains.python;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.PathUtil;
import org.jetbrains.annotations.NonNls;

import java.io.File;

public class PythonHelpersLocator {
  private static final Logger LOG = Logger.getInstance("#com.jetbrains.python.PythonHelpersLocator");

  private PythonHelpersLocator() {
  }

  /**
   * @return the base directory under which various scripts, etc are stored.
   */
  public static File getHelpersRoot() {
    @NonNls final String jarPath = PathUtil.getJarPathForClass(PythonHelpersLocator.class);
    if (jarPath.endsWith(".jar")) {
      final File jarFile = new File(jarPath);

      LOG.assertTrue(jarFile.exists(), "jar file cannot be null");
      File pluginBaseDir = jarFile.getParentFile().getParentFile();
      return new File(pluginBaseDir, "helpers");
    }
    return new File(jarPath + "-helpers");
  }

  /**
   * Find a resource by name under helper root.
   * @param resourceName a path relative to helper root
   * @return absolute path of the resource
   */
  public static String getHelperPath(String resourceName) {
    return getHelperFile(resourceName).getAbsolutePath();
  }

  /**
   * Finds a resource file by name under helper root.
   * @param resourceName a path relative to helper root
   * @return a file object pointing to that path; existence is not checked.
   */
  public static File getHelperFile(String resourceName) {
    return new File(getHelpersRoot(), resourceName);
  }

}

@@ -309,16 +309,80 @@
 tor%22);%0A%0A
+  private static final String COMMUNITY_SUFFIX = %22-community%22;%0A%0A
   privat
@@ -408,16 +408,16 @@
 tor() %7B%0A
-
   %7D%0A%0A  /
@@ -554,22 +554,16 @@
 @NonNls 
-final 
 String j
@@ -899,14 +899,152 @@
 %22);%0A
-
     %7D%0A
+%0A    if (jarPath.endsWith(COMMUNITY_SUFFIX)) %7B%0A      jarPath = jarPath.substring(0, jarPath.length() - COMMUNITY_SUFFIX.length());%0A    %7D%0A%0A
     

fix helpers locator when running pycharm from idea