Search in sources :

Example 1 with PySkeletonGenerator

use of com.jetbrains.python.sdk.skeletons.PySkeletonGenerator in project intellij-community by JetBrains.

the class GenerateBinaryStubsFix method generateSkeletonsForList.

private boolean generateSkeletonsForList(@NotNull final PySkeletonRefresher refresher, ProgressIndicator indicator, @Nullable final String currentBinaryFilesPath) throws InvalidSdkException {
    final PySkeletonGenerator generator = new PySkeletonGenerator(refresher.getSkeletonsPath(), mySdk, currentBinaryFilesPath);
    indicator.setIndeterminate(false);
    final String homePath = mySdk.getHomePath();
    if (homePath == null)
        return false;
    GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
    final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd, new File(homePath).getParent(), PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000);
    if (runResult.getExitCode() == 0 && !runResult.isTimeout()) {
        final String extraPath = runResult.getStdout();
        final PySkeletonGenerator.ListBinariesResult binaries = generator.listBinaries(mySdk, extraPath);
        final List<String> names = Lists.newArrayList(binaries.modules.keySet());
        Collections.sort(names);
        final int size = names.size();
        for (int i = 0; i != size; ++i) {
            final String name = names.get(i);
            indicator.setFraction((double) i / size);
            if (needBinaryList(name)) {
                indicator.setText2(name);
                final PySkeletonRefresher.PyBinaryItem item = binaries.modules.get(name);
                final String modulePath = item != null ? item.getPath() : "";
                //noinspection unchecked
                refresher.generateSkeleton(name, modulePath, new ArrayList<>(), Consumer.EMPTY_CONSUMER);
            }
        }
    }
    return true;
}
Also used : PySkeletonRefresher(com.jetbrains.python.sdk.skeletons.PySkeletonRefresher) GeneralCommandLine(com.intellij.execution.configurations.GeneralCommandLine) ProcessOutput(com.intellij.execution.process.ProcessOutput) PySkeletonGenerator(com.jetbrains.python.sdk.skeletons.PySkeletonGenerator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Aggregations

GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 ProcessOutput (com.intellij.execution.process.ProcessOutput)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 PySkeletonGenerator (com.jetbrains.python.sdk.skeletons.PySkeletonGenerator)1 PySkeletonRefresher (com.jetbrains.python.sdk.skeletons.PySkeletonRefresher)1 File (java.io.File)1