Beispiel #1
0
 /** Adds new CLASSES entries found in sys.path. */
 private static boolean addNewSysPathEntries(
     @NotNull Sdk sdk, @NotNull SdkModificator modificator, @NotNull List<String> sysPath) {
   final List<VirtualFile> oldRoots =
       Arrays.asList(sdk.getRootProvider().getFiles(OrderRootType.CLASSES));
   PythonSdkAdditionalData additionalData =
       sdk.getSdkAdditionalData() instanceof PythonSdkAdditionalData
           ? (PythonSdkAdditionalData) sdk.getSdkAdditionalData()
           : null;
   List<String> newRoots = new ArrayList<String>();
   for (String root : sysPath) {
     if (new File(root).exists()
         && !FileUtilRt.extensionEquals(root, "egg-info")
         && (additionalData == null || !wasOldRoot(root, additionalData.getExcludedPathFiles()))
         && !wasOldRoot(root, oldRoots)) {
       newRoots.add(root);
     }
   }
   if (!newRoots.isEmpty()) {
     for (String root : newRoots) {
       PythonSdkType.addSdkRoot(modificator, root);
     }
     return true;
   }
   return false;
 }
 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);
   }
 }