public static boolean isIpythonNewFormat()

in src/org/jetbrains/plugins/ipnb/format/IpnbParser.java [102:120]


  public static boolean isIpythonNewFormat(@NotNull final VirtualFile virtualFile) {
    final Project project = ProjectUtil.guessProjectForFile(virtualFile);
    if (project != null) {
      final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
      if (module != null) {
        final Sdk sdk = PythonSdkType.findPythonSdk(module);
        if (sdk != null) {
          // It should be called first before IpnbConnectionManager#startIpythonServer()
          final List<PyPackage> packages = PyPackageUtil.refreshAndGetPackagesModally(sdk);
          final PyPackage ipython = packages != null ? PyPackageUtil.findPackage(packages, "ipython") : null;
          final PyPackage jupyter = packages != null ? PyPackageUtil.findPackage(packages, "jupyter") : null;
          if (jupyter == null && ipython != null && VersionComparatorUtil.compare(ipython.getVersion(), "3.0") <= 0) {
            return false;
          }
        }
      }
    }
    return true;
  }