public static void initPythonPath(
     GeneralCommandLine commandLine,
     boolean passParentEnvs,
     List<String> pathList,
     final String interpreterPath) {
   final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(interpreterPath);
   if (flavor != null) {
     flavor.initPythonPath(commandLine, pathList);
   } else {
     PythonSdkFlavor.initPythonPath(commandLine.getEnvironment(), passParentEnvs, pathList);
   }
 }
  public static Map<String, String> addDefaultEnvironments(Sdk sdk, Map<String, String> envs) {
    Charset defaultCharset = EncodingManager.getInstance().getDefaultCharset();

    final String encoding = defaultCharset != null ? defaultCharset.name() : "utf-8";
    setPythonIOEncoding(setPythonUnbuffered(envs), encoding);

    PythonSdkFlavor.initPythonPath(envs, true, PythonCommandLineState.getAddedPaths(sdk));
    return envs;
  }
  @Override
  public void customize(JList list, Object item, int index, boolean selected, boolean hasFocus) {
    if (item instanceof Sdk) {
      Sdk sdk = (Sdk) item;
      final PythonSdkFlavor flavor =
          PythonSdkFlavor.getPlatformIndependentFlavor(sdk.getHomePath());
      final Icon icon = flavor != null ? flavor.getIcon() : ((SdkType) sdk.getSdkType()).getIcon();

      String name;
      if (mySdkModifiers != null && mySdkModifiers.containsKey(sdk)) {
        name = mySdkModifiers.get(sdk).getName();
      } else {
        name = sdk.getName();
      }
      if (name.startsWith("Remote")) {
        final String trimmedRemote = StringUtil.trim(name.substring("Remote".length()));
        if (!trimmedRemote.isEmpty()) name = trimmedRemote;
      }
      final String flavorName = flavor == null ? "Python" : flavor.getName();
      if (name.startsWith(flavorName)) name = StringUtil.trim(name.substring(flavorName.length()));

      if (isShortVersion) {
        name = shortenName(name);
      }

      if (PythonSdkType.isInvalid(sdk)) {
        setText("[invalid] " + name);
        setIcon(wrapIconWithWarningDecorator(icon));
      } else if (PythonSdkType.isIncompleteRemote(sdk)) {
        setText("[incomplete] " + name);
        setIcon(wrapIconWithWarningDecorator(icon));
      } else if (sdk instanceof PyDetectedSdk) {
        setText(name);
        setIcon(IconLoader.getTransparentIcon(icon));
      } else {
        setText(name);
        setIcon(icon);
      }
    } else if (SEPARATOR.equals(item)) setSeparator();
    else if (item == null) setText(myNullText);
  }
 private void setSdkAssociated(SdkModificator modificator, boolean isAssociated) {
   PythonSdkAdditionalData additionalData =
       (PythonSdkAdditionalData) modificator.getSdkAdditionalData();
   if (additionalData == null) {
     additionalData =
         new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(modificator.getHomePath()));
     modificator.setSdkAdditionalData(additionalData);
   }
   if (isAssociated) {
     additionalData.associateWithProject(myProject);
   } else {
     additionalData.setAssociatedProjectPath(null);
   }
 }
 /**
  * Checks if this fix can help you to generate binary stubs
  *
  * @param importStatementBase statement to fix
  * @return true if this fix could work
  */
 public static boolean isApplicable(@NotNull final PyImportStatementBase importStatementBase) {
   if (importStatementBase.getFullyQualifiedObjectNames().isEmpty()
       && !(importStatementBase instanceof PyFromImportStatement
           && ((PyFromImportStatement) importStatementBase).isStarImport())) {
     return false;
   }
   final Sdk sdk = getPythonSdk(importStatementBase);
   if (sdk == null) {
     return false;
   }
   final PythonSdkFlavor flavor = PythonSdkFlavor.getFlavor(sdk);
   if (flavor instanceof IronPythonSdkFlavor) {
     return true;
   }
   return isGtk(importStatementBase);
 }
 private List<String> collectAssemblyReferences(PsiFile file) {
   if (!(PythonSdkFlavor.getFlavor(mySdk) instanceof IronPythonSdkFlavor)) {
     return Collections.emptyList();
   }
   final List<String> result = new ArrayList<String>();
   file.accept(
       new PyRecursiveElementVisitor() {
         @Override
         public void visitPyCallExpression(PyCallExpression node) {
           super.visitPyCallExpression(node);
           // TODO: What if user loads it not by literal? We need to ask user for list of DLLs
           if (node.isCalleeText(
               "AddReference", "AddReferenceByPartialName", "AddReferenceByName")) {
             final PyExpression[] args = node.getArguments();
             if (args.length == 1 && args[0] instanceof PyStringLiteralExpression) {
               result.add(((PyStringLiteralExpression) args[0]).getStringValue());
             }
           }
         }
       });
   return result;
 }
 private static void setupEncodingEnvs(Map<String, String> envs, Charset charset) {
   PythonSdkFlavor.setupEncodingEnvs(envs, charset);
 }
 @Nullable
 public PythonSdkFlavor getSdkFlavor() {
   return PythonSdkFlavor.getFlavor(myConfig.getInterpreterPath());
 }