当前位置: 首页>>代码示例>>Java>>正文


Java PythonSdkType.getVirtualEnvRoot方法代码示例

本文整理汇总了Java中com.jetbrains.python.sdk.PythonSdkType.getVirtualEnvRoot方法的典型用法代码示例。如果您正苦于以下问题:Java PythonSdkType.getVirtualEnvRoot方法的具体用法?Java PythonSdkType.getVirtualEnvRoot怎么用?Java PythonSdkType.getVirtualEnvRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jetbrains.python.sdk.PythonSdkType的用法示例。


在下文中一共展示了PythonSdkType.getVirtualEnvRoot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findVirtualEnvLibDir

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
public static VirtualFile findVirtualEnvLibDir(Sdk sdk) {
  VirtualFile[] classVFiles = sdk.getRootProvider().getFiles(OrderRootType.CLASSES);
  String homePath = sdk.getHomePath();
  if (homePath != null) {
    File root = PythonSdkType.getVirtualEnvRoot(homePath);
    if (root != null) {
      File libRoot = new File(root, "lib");
      File[] versionRoots = libRoot.listFiles();
      if (versionRoots != null && versionRoots.length == 1) {
        libRoot = versionRoots[0];
      }
      for (VirtualFile file : classVFiles) {
        if (FileUtil.pathsEqual(file.getPath(), libRoot.getPath())) {
          return file;
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyProjectScopeBuilder.java

示例2: isValidSdkPath

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
@Override
public boolean isValidSdkPath(@NotNull File file) {
  if (!super.isValidSdkPath(file)) return false;
  return PythonSdkType.getVirtualEnvRoot(file.getPath()) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:VirtualEnvSdkFlavor.java

示例3: configureProject

import com.jetbrains.python.sdk.PythonSdkType; //导入方法依赖的package包/类
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, Ref<Module> moduleRef) {
  // it it a virtualenv?
  final PythonSdkType sdkType = PythonSdkType.getInstance();
  //find virtualEnv in project directory
  final List<String> candidates = new ArrayList<String>();
  if (project == null) return;
  final VirtualFile rootDir = project.getBaseDir();
  if (rootDir != null)
    candidates.addAll(VirtualEnvSdkFlavor.findInDirectory(rootDir));
  if (!candidates.isEmpty()) {
    String filePath = candidates.get(0);
    if (StringUtil.startsWithChar(filePath, '~')) {
      final String home = SystemProperties.getUserHome();
      filePath = home + filePath.substring(1);
    }
    final Sdk virtualEnvSdk = SdkConfigurationUtil.createAndAddSDK(filePath, sdkType);
    if (virtualEnvSdk != null) {
      SdkConfigurationUtil.setDirectoryProjectSdk(project, virtualEnvSdk);
      SdkAdditionalData additionalData = virtualEnvSdk.getSdkAdditionalData();
      if (additionalData == null) {
        additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(virtualEnvSdk.getHomePath()));
        ((ProjectJdkImpl)virtualEnvSdk).setSdkAdditionalData(additionalData);
      }
      ((PythonSdkAdditionalData) additionalData).associateWithProject(project);
      return;
    }
    return;
  }

  
  final Sdk existingSdk = ProjectRootManager.getInstance(project).getProjectSdk();
  if (existingSdk != null && existingSdk.getSdkType() == sdkType) return; // SdkConfigurationUtil does the same
  final File executableFile = PythonSdkType.findExecutableFile(new File(project.getBasePath(), "bin"), "python");
  if (executableFile != null) {
    final File virtualEnvRoot = PythonSdkType.getVirtualEnvRoot(executableFile.getPath());
    if (virtualEnvRoot != null) {
      // yes, an unknown virtualenv; set it up as SDK
      final Sdk sdk = SdkConfigurationUtil.createAndAddSDK(executableFile.getPath(), sdkType);
      if (sdk != null) {
        SdkConfigurationUtil.setDirectoryProjectSdk(project, sdk);
        return;
      }
    }
  }
  // default
  SdkConfigurationUtil.configureDirectoryProjectSdk(project, new PreferredSdkComparator(), sdkType);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:PythonSdkConfigurator.java


注:本文中的com.jetbrains.python.sdk.PythonSdkType.getVirtualEnvRoot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。