Move helpers enum to separate class.

This commit is contained in:
Dmitry Trofimov
2015-08-10 10:55:58 +02:00
parent 4e137f0ef0
commit 76df7fdddc
26 changed files with 274 additions and 257 deletions
@@ -28,7 +28,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.HyperlinkAdapter;
import com.intellij.util.Alarm;
import com.intellij.util.io.HttpRequests;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.packaging.PyPackage;
import com.jetbrains.python.packaging.PyPackageManager;
import com.jetbrains.python.sdk.PythonSdkType;
@@ -284,7 +284,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
parameters.add(hostPort.getSecond());
}
final GeneralCommandLine commandLine = PythonHelpersLocator.LOAD_ENTRY_POINT
final GeneralCommandLine commandLine = PythonHelper.LOAD_ENTRY_POINT
.newCommandLine(sdk.getHomePath(), parameters)
.withWorkDirectory(myProject.getBasePath()).
withEnvironment(env);
@@ -26,8 +26,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.run.PythonCommandLineState;
import com.jetbrains.python.run.PythonProcessRunner;
import org.jetbrains.annotations.Nullable;
@@ -105,7 +104,7 @@ public abstract class RestCommandLineState extends PythonCommandLineState {
return null;
}
protected abstract PythonHelper getRunner();
protected abstract HelperPackage getRunner();
protected abstract String getTask();
@@ -19,8 +19,8 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.ide.BrowserUtil;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.rest.run.RestCommandLineState;
import org.jetbrains.annotations.Nullable;
@@ -53,8 +53,8 @@ public class DocutilsCommandLineState extends RestCommandLineState {
}
@Override
protected PythonHelper getRunner() {
return PythonHelpersLocator.REST_RUNNER;
protected HelperPackage getRunner() {
return PythonHelper.REST_RUNNER;
}
@Override
@@ -18,8 +18,8 @@ package com.jetbrains.rest.run.sphinx;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.rest.run.RestCommandLineState;
import java.util.Collections;
@@ -47,8 +47,8 @@ public class SphinxCommandLineState extends RestCommandLineState {
}
@Override
protected PythonHelper getRunner() {
return PythonHelpersLocator.SPHINX_RUNNER;
protected HelperPackage getRunner() {
return PythonHelper.SPHINX_RUNNER;
}
@Override
@@ -31,7 +31,7 @@ import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.ReSTService;
import com.jetbrains.python.buildout.BuildoutFacet;
import com.jetbrains.python.run.PythonCommandLineState;
@@ -148,7 +148,7 @@ public class SphinxBaseCommand {
String sdkHomePath = sdk.getHomePath();
final GeneralCommandLine cmd = PythonHelpersLocator.LOAD_ENTRY_POINT.newCommandLine(sdkHomePath, Lists.<String>newArrayList());
final GeneralCommandLine cmd = PythonHelper.LOAD_ENTRY_POINT.newCommandLine(sdkHomePath, Lists.<String>newArrayList());
cmd.setWorkDirectory(service.getWorkdir().isEmpty()? module.getProject().getBaseDir().getPath(): service.getWorkdir());
PythonCommandLineState.createStandardGroups(cmd);
@@ -0,0 +1,38 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jetbrains.python;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.ParamsGroup;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
/**
* @author traff
*/
public interface HelperPackage {
void addToPythonPath(@NotNull Map<String, String> environment);
String getPythonPath();
void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd);
String asParamString();
GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters);
}
@@ -15,24 +15,193 @@
*/
package com.jetbrains.python;
import com.google.common.collect.Lists;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.ParamsGroup;
import com.intellij.openapi.util.io.FileUtil;
import com.jetbrains.python.sdk.PythonEnvUtil;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.util.Map;
import static com.jetbrains.python.PythonHelpersLocator.getHelperFile;
import static com.jetbrains.python.PythonHelpersLocator.getHelpersRoot;
/**
* @author traff
*/
public interface PythonHelper {
void addToPythonPath(@NotNull Map<String, String> environment);
public enum PythonHelper implements HelperPackage {
COVERAGEPY("coveragepy", ""), COVERAGE("coverage_runner", "run_coverage"),
DEBUGGER("pydev", "pydevd"),
ATTACH_DEBUGGER("pydev", "pydevd_attach_to_process.attach_pydevd"),
String getPythonPath();
CONSOLE("pydev", "pydevconsole"),
RUN_IN_CONSOLE("pydev", "pydev_run_in_console"),
PROFILER("profiler", "run_profiler"),
void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd);
LOAD_ENTRY_POINT("pycharm", "pycharm_load_entry_point"),
String asParamString();
// Test runners
UT("pycharm", "utrunner"),
SETUPPY("pycharm", "pycharm_setup_runner"),
NOSE("pycharm", "noserunner"),
PYTEST("pycharm", "pytestrunner"),
ATTEST("pycharm", "attestrunner"),
DOCSTRING("pycharm", "docrunner"),
BEHAVE("pycharm", "behave_runner"),
LETTUCE("pycharm", "lettuce_runner"),
DJANGO_TEST_MANAGE("pycharm", "django_test_manage"),
DJANGO_MANAGE("pycharm", "django_manage"),
MANAGE_TASKS_PROVIDER("pycharm", "_jb_manage_tasks_provider"),
BUILDOUT_ENGULFER("pycharm", "buildout_engulfer"),
EPYDOC_FORMATTER("epydoc_formatter.py"),
REST_FORMATTER("rest_formatter.py"),
EXTRA_SYSPATH("extra_syspath.py"),
SYSPATH("syspath.py"),
PEP8("pep8.py"),
REST_RUNNER("rest_runners/rst2smth.py"),
SPHINX_RUNNER("rest_runners/sphinx_runner.py");
@NotNull
private static PathHelperPackage findModule(String moduleEntryPoint, String path) {
if (getHelperFile(path + ".zip").isFile()) {
return new ModuleHelperPackage(moduleEntryPoint, path + ".zip");
}
if (getHelperFile(path).isDirectory()) {
return new ModuleHelperPackage(moduleEntryPoint, path);
}
return new ScriptPythonHelper(path, getHelpersRoot());
}
private PathHelperPackage myModule;
PythonHelper(String pythonPath, String moduleName) {
myModule = findModule(moduleName, pythonPath);
}
PythonHelper(String helperScript) {
myModule = new ScriptPythonHelper(helperScript, getHelpersRoot());
}
public String getPythonPath() {
return myModule.getPythonPath();
}
public abstract static class PathHelperPackage implements HelperPackage {
protected final File myPath;
PathHelperPackage(String path) {
myPath = new File(path);
}
@Override
public void addToPythonPath(@NotNull Map<String, String> environment) {
PythonEnvUtil.addToPythonPath(environment, myPath.getAbsolutePath());
}
@Override
public void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd) {
addToPythonPath(cmd.getEnvironment());
group.addParameter(asParamString());
}
@Override
public String asParamString() {
return FileUtil.toSystemDependentName(myPath.getAbsolutePath());
}
@Override
public GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters) {
List<String> args = Lists.newArrayList();
args.add(sdkPath);
args.add(asParamString());
args.addAll(parameters);
GeneralCommandLine cmd = new GeneralCommandLine(args);
addToPythonPath(cmd.getEnvironment());
return cmd;
}
}
/**
* Module Python helper can be executed from zip-archive
*/
public static class ModuleHelperPackage extends PathHelperPackage {
private final String myModuleName;
public ModuleHelperPackage(String moduleName, String relativePath) {
super(getHelperFile(relativePath).getAbsolutePath());
this.myModuleName = moduleName;
}
@Override
public String asParamString() {
return "-m" + myModuleName;
}
@Override
public String getPythonPath() {
return FileUtil.toSystemDependentName(myPath.getAbsolutePath());
}
}
/**
* Script Python helper can be executed as a Python script, therefore
* PYTHONDONTWRITEBYTECODE option is set not to spoil installation
* with .pyc files
*/
public static class ScriptPythonHelper extends PathHelperPackage {
private String myPythonPath;
public ScriptPythonHelper(String script, File pythonPath) {
super(new File(pythonPath, script).getAbsolutePath());
myPythonPath = pythonPath.getAbsolutePath();
}
@Override
public void addToPythonPath(@NotNull Map<String, String> environment) {
PythonEnvUtil.setPythonDontWriteBytecode(environment);
PythonEnvUtil.addToPythonPath(environment, myPythonPath);
}
@Override
public String getPythonPath() {
return myPythonPath;
}
}
@Override
public void addToPythonPath(@NotNull Map<String, String> environment) {
myModule.addToPythonPath(environment);
}
@Override
public void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd) {
myModule.addToGroup(group, cmd);
}
@Override
public String asParamString() {
return myModule.asParamString();
}
@Override
public GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters) {
return myModule.newCommandLine(sdkPath, parameters);
}
GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters);
}
@@ -15,97 +15,17 @@
*/
package com.jetbrains.python;
import com.google.common.collect.Lists;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.ParamsGroup;
import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.PathUtil;
import com.jetbrains.python.sdk.PythonEnvUtil;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.util.Map;
public enum PythonHelpersLocator implements PythonHelper {
COVERAGEPY("coveragepy", ""), COVERAGE("coverage_runner", "run_coverage"),
DEBUGGER("pydev", "pydevd"),
ATTACH_DEBUGGER("pydev", "pydevd_attach_to_process.attach_pydevd"),
CONSOLE("pydev", "pydevconsole"),
RUN_IN_CONSOLE("pydev", "pydev_run_in_console"),
PROFILER("profiler", "run_profiler"),
LOAD_ENTRY_POINT("pycharm", "pycharm_load_entry_point"),
// Test runners
UT("pycharm", "utrunner"),
SETUPPY("pycharm", "pycharm_setup_runner"),
NOSE("pycharm", "noserunner"),
PYTEST("pycharm", "pytestrunner"),
ATTEST("pycharm", "attestrunner"),
DOCSTRING("pycharm", "docrunner"),
BEHAVE("pycharm", "behave_runner"),
LETTUCE("pycharm", "lettuce_runner"),
DJANGO_TEST_MANAGE("pycharm", "django_test_manage"),
DJANGO_MANAGE("pycharm", "django_manage"),
MANAGE_TASKS_PROVIDER("pycharm", "_jb_manage_tasks_provider"),
BUILDOUT_ENGULFER("pycharm", "buildout_engulfer"),
EPYDOC_FORMATTER("epydoc_formatter.py"),
REST_FORMATTER("rest_formatter.py"),
EXTRA_SYSPATH("extra_syspath.py"),
SYSPATH("syspath.py"),
PEP8("pep8.py"),
REST_RUNNER("rest_runners/rst2smth.py"),
SPHINX_RUNNER("rest_runners/sphinx_runner.py")
;
@NotNull
private static PathPythonHelper findModule(String moduleEntryPoint, String path) {
if (getHelperFile(path + ".zip").isFile()) {
return new ModulePythonHelper(moduleEntryPoint, path + ".zip");
}
if (getHelperFile(path).isDirectory()) {
return new ModulePythonHelper(moduleEntryPoint, path);
}
return new ScriptPythonHelper(path, getHelpersRoot());
}
public class PythonHelpersLocator {
private static final Logger LOG = Logger.getInstance("#com.jetbrains.python.PythonHelpersLocator");
private static final String COMMUNITY_SUFFIX = "-community";
private PathPythonHelper myModule;
PythonHelpersLocator(String pythonPath, String moduleName) {
myModule = findModule(moduleName, pythonPath);
}
PythonHelpersLocator(String helperScript) {
myModule = new ScriptPythonHelper(helperScript, getHelpersRoot());
}
public String getPythonPath() {
return myModule.getPythonPath();
}
/**
* @return the base directory under which various scripts, etc are stored.
*/
@@ -155,109 +75,4 @@ public enum PythonHelpersLocator implements PythonHelper {
return new File(PathManager.getHomePath(), "python").getPath();
}
public abstract static class PathPythonHelper implements PythonHelper {
protected final File myPath;
PathPythonHelper(String path) {
myPath = new File(path);
}
@Override
public void addToPythonPath(@NotNull Map<String, String> environment) {
PythonEnvUtil.addToPythonPath(environment, myPath.getAbsolutePath());
}
@Override
public void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd) {
addToPythonPath(cmd.getEnvironment());
group.addParameter(asParamString());
}
@Override
public String asParamString() {
return FileUtil.toSystemDependentName(myPath.getAbsolutePath());
}
@Override
public GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters) {
List<String> args = Lists.newArrayList();
args.add(sdkPath);
args.add(asParamString());
args.addAll(parameters);
GeneralCommandLine cmd = new GeneralCommandLine(args);
addToPythonPath(cmd.getEnvironment());
return cmd;
}
}
/**
* Module Python helper can be executed from zip-archive
*/
public static class ModulePythonHelper extends PathPythonHelper {
private final String myModuleName;
public ModulePythonHelper(String moduleName, String relativePath) {
super(getHelperFile(relativePath).getAbsolutePath());
this.myModuleName = moduleName;
}
@Override
public String asParamString() {
return "-m" + myModuleName;
}
@Override
public String getPythonPath() {
return FileUtil.toSystemDependentName(myPath.getAbsolutePath());
}
}
/**
* Script Python helper can be executed as a Python script, therefore
* PYTHONDONTWRITEBYTECODE option is set not to spoil installation
* with .pyc files
*/
public static class ScriptPythonHelper extends PathPythonHelper {
private String myPythonPath;
public ScriptPythonHelper(String script, File pythonPath) {
super(new File(pythonPath, script).getAbsolutePath());
myPythonPath = pythonPath.getAbsolutePath();
}
@Override
public void addToPythonPath(@NotNull Map<String, String> environment) {
PythonEnvUtil.setPythonDontWriteBytecode(environment);
PythonEnvUtil.addToPythonPath(environment, myPythonPath);
}
@Override
public String getPythonPath() {
return myPythonPath;
}
}
@Override
public void addToPythonPath(@NotNull Map<String, String> environment) {
myModule.addToPythonPath(environment);
}
@Override
public void addToGroup(@NotNull ParamsGroup group, @NotNull GeneralCommandLine cmd) {
myModule.addToGroup(group, cmd);
}
@Override
public String asParamString() {
return myModule.asParamString();
}
@Override
public GeneralCommandLine newCommandLine(String sdkPath, List<String> parameters) {
return myModule.newCommandLine(sdkPath, parameters);
}
}
@@ -36,6 +36,7 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.*;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiFileFactory;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.buildout.config.BuildoutCfgLanguage;
@@ -292,7 +293,7 @@ public class BuildoutFacet extends Facet<BuildoutFacetConfiguration> implements
assert scriptParams != null;
if (scriptParams.getParameters().size() > 0) {
String normalScript = scriptParams.getParameters().get(0); // expect DjangoUtil.MANAGE_FILE
PythonHelper engulfer = PythonHelpersLocator.BUILDOUT_ENGULFER;
HelperPackage engulfer = PythonHelper.BUILDOUT_ENGULFER;
env.put("PYCHARM_ENGULF_SCRIPT", getConfiguration().getScriptName());
scriptParams.getParametersList().replaceOrPrepend(normalScript, engulfer.asParamString());
}
@@ -79,7 +79,7 @@ import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.console.completion.PydevConsoleElement;
import com.jetbrains.python.console.parsing.PythonConsoleData;
import com.jetbrains.python.console.pydev.ConsoleCommunication;
@@ -379,18 +379,18 @@ public class PydevConsoleRunner extends AbstractConsoleRunnerWithHistory<PythonC
protected GeneralCommandLine createCommandLine(@NotNull final Sdk sdk,
@NotNull final Map<String, String> environmentVariables,
int[] ports) {
return doCreateConsoleCmdLine(ports, PythonHelpersLocator.CONSOLE);
return doCreateConsoleCmdLine(ports, PythonHelper.CONSOLE);
}
@NotNull
protected GeneralCommandLine doCreateConsoleCmdLine(int[] ports, PythonHelpersLocator helpersLocator) {
protected GeneralCommandLine doCreateConsoleCmdLine(int[] ports, PythonHelper helper) {
PyConsoleOptions.PyConsoleSettings settings = PyConsoleOptions.getInstance(getProject()).getPythonConsoleSettings();
GeneralCommandLine cmd = PythonCommandLineState.createPythonCommandLine(getProject(), settings);
cmd.withWorkDirectory(getWorkingDir());
ParamsGroup group = cmd.getParametersList().getParamsGroup(PythonCommandLineState.GROUP_SCRIPT);
helpersLocator.addToGroup(group, cmd);
helper.addToGroup(group, cmd);
for (int port : ports) {
group.addParameter(String.valueOf(port));
@@ -36,7 +36,7 @@ import com.intellij.xdebugger.XDebugProcess;
import com.intellij.xdebugger.XDebugProcessStarter;
import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XDebuggerManager;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.console.PythonConsoleView;
import com.jetbrains.python.console.PythonDebugConsoleCommunication;
import com.jetbrains.python.console.PythonDebugLanguageConsoleView;
@@ -235,7 +235,7 @@ public class PyDebugRunner extends GenericProgramRunner {
int serverLocalPort,
@NotNull PythonCommandLineState pyState,
@NotNull GeneralCommandLine cmd) {
PythonHelpersLocator.DEBUGGER.addToGroup(debugParams, cmd);
PythonHelper.DEBUGGER.addToGroup(debugParams, cmd);
if (pyState.isMultiprocessDebug()) {
//noinspection SpellCheckingInspection
@@ -11,7 +11,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.debugger.PyRemoteDebugProcess;
import com.jetbrains.python.debugger.PyRemoteDebugProcessAware;
import com.jetbrains.python.run.PythonConfigurationType;
@@ -36,7 +36,7 @@ public class PyAttachToProcessCommandLineState extends PythonScriptCommandLineSt
throws ExecutionException {
PythonRunConfiguration conf =
(PythonRunConfiguration)PythonConfigurationType.getInstance().getFactory().createTemplateConfiguration(project);
conf.setScriptName(PythonHelpersLocator.ATTACH_DEBUGGER.asParamString());
conf.setScriptName(PythonHelper.ATTACH_DEBUGGER.asParamString());
conf.setSdkHome(sdkPath);
conf.setScriptParameters("--port " + port + " --pid " + pid);
@@ -16,7 +16,6 @@
package com.jetbrains.python.documentation;
import com.google.common.collect.Lists;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.process.ProcessOutput;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
@@ -26,8 +25,8 @@ import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.encoding.EncodingProjectManager;
import com.intellij.psi.PsiElement;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.psi.StructuredDocString;
import com.jetbrains.python.sdk.PySdkUtil;
import com.jetbrains.python.sdk.PythonEnvUtil;
@@ -68,17 +67,17 @@ public class PyStructuredDocstringFormatter {
final String[] lines = PyDocumentationBuilder.removeCommonIndentation(docstring);
final String preparedDocstring = StringUtil.join(lines, "\n");
final PythonHelper formatter;
final HelperPackage formatter;
final StructuredDocStringBase structuredDocString;
if (documentationSettings.isEpydocFormat(element.getContainingFile()) ||
DocStringUtil.isEpydocDocString(preparedDocstring)) {
formatter = PythonHelpersLocator.EPYDOC_FORMATTER;
formatter = PythonHelper.EPYDOC_FORMATTER;
structuredDocString = new EpydocString(preparedDocstring);
result.add(formatStructuredDocString(structuredDocString));
}
else if (documentationSettings.isReSTFormat(element.getContainingFile()) ||
DocStringUtil.isSphinxDocString(preparedDocstring)) {
formatter = PythonHelpersLocator.REST_FORMATTER;
formatter = PythonHelper.REST_FORMATTER;
structuredDocString = new SphinxDocString(preparedDocstring);
}
else {
@@ -96,7 +95,7 @@ public class PyStructuredDocstringFormatter {
@Nullable
private static String runExternalTool(@NotNull final Module module,
@NotNull final PythonHelper formatter,
@NotNull final HelperPackage formatter,
@NotNull final String docstring) {
final Sdk sdk = PythonSdkType.findPython2Sdk(module);
if (sdk == null) return null;
@@ -39,7 +39,7 @@ import com.intellij.psi.PsiFile;
import com.intellij.psi.util.QualifiedName;
import com.intellij.util.Consumer;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.psi.*;
import com.jetbrains.python.sdk.InvalidSdkException;
import com.jetbrains.python.sdk.PySdkUtil;
@@ -173,7 +173,7 @@ public class GenerateBinaryStubsFix implements LocalQuickFix {
indicator.setIndeterminate(false);
final String homePath = mySdk.getHomePath();
if (homePath == null) return false;
GeneralCommandLine cmd = PythonHelpersLocator.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd,
new File(homePath).getParent(),
PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000
@@ -30,7 +30,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ArrayUtil;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.console.PyConsoleType;
import com.jetbrains.python.console.PydevConsoleRunner;
import com.jetbrains.python.sdk.PythonEnvUtil;
@@ -128,7 +128,7 @@ public class PythonScriptCommandLineState extends PythonCommandLineState {
protected GeneralCommandLine createCommandLine(@NotNull Sdk sdk,
@NotNull Map<String, String> environmentVariables,
int[] ports) {
GeneralCommandLine consoleCmdLine = doCreateConsoleCmdLine(ports, PythonHelpersLocator.RUN_IN_CONSOLE);
GeneralCommandLine consoleCmdLine = doCreateConsoleCmdLine(ports, PythonHelper.RUN_IN_CONSOLE);
final GeneralCommandLine cmd = generateCommandLine(myPatchers);
@@ -33,8 +33,8 @@ import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.NotNullFunction;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.buildout.BuildoutFacet;
import com.jetbrains.python.console.PydevConsoleRunner;
import com.jetbrains.python.sdk.PySdkUtil;
@@ -61,7 +61,7 @@ public class PythonTask {
private final Sdk mySdk;
private String myWorkingDirectory;
private String myRunnerScript;
private PythonHelper myHelper = null;
private HelperPackage myHelper = null;
private List<String> myParameters = new ArrayList<String>();
private final String myRunTabTitle;
@@ -93,7 +93,7 @@ public class PythonTask {
myRunnerScript = script;
}
public void setHelper(PythonHelper helper) {
public void setHelper(HelperPackage helper) {
myHelper = helper;
}
@@ -65,7 +65,7 @@ import com.intellij.util.NullableConsumer;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.codeInsight.userSkeletons.PyUserSkeletonsUtil;
import com.jetbrains.python.facet.PythonFacetSettings;
import com.jetbrains.python.psi.LanguageLevel;
@@ -769,7 +769,7 @@ public class PythonSdkType extends SdkType {
public static List<String> getSysPathsFromScript(@NotNull String binaryPath) throws InvalidSdkException {
// to handle the situation when PYTHONPATH contains ., we need to run the syspath script in the
// directory of the script itself - otherwise the dir in which we run the script (e.g. /usr/bin) will be added to SDK path
GeneralCommandLine cmd = PythonHelpersLocator.SYSPATH.newCommandLine(binaryPath, Lists.<String>newArrayList());
GeneralCommandLine cmd = PythonHelper.SYSPATH.newCommandLine(binaryPath, Lists.<String>newArrayList());
final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd, new File(binaryPath).getParent(),
getVirtualEnvExtraEnv(binaryPath), MINUTE);
if (!runResult.checkSuccess(LOG)) {
@@ -30,8 +30,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.ComponentContainer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.search.GlobalSearchScope;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.run.AbstractPythonRunConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -101,7 +100,7 @@ public class PyRerunFailedTestsAction extends AbstractRerunFailedTestsAction {
}
@Override
protected PythonHelper getRunner() {
protected HelperPackage getRunner() {
return myState.getRunner();
}
@@ -36,7 +36,7 @@ import com.intellij.openapi.util.Getter;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.console.PythonDebugLanguageConsoleView;
import com.jetbrains.python.run.AbstractPythonRunConfiguration;
@@ -45,7 +45,6 @@ import com.jetbrains.python.run.PythonCommandLineState;
import com.jetbrains.python.sdk.PythonSdkType;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.List;
import java.util.Map;
@@ -173,6 +172,6 @@ public abstract class PythonTestCommandLineStateBase extends PythonCommandLineSt
envs.put("PYCHARM_HELPERS_DIR", PythonHelpersLocator.getHelperPath("pycharm"));
}
protected abstract PythonHelper getRunner();
protected abstract HelperPackage getRunner();
protected abstract List<String> getTestSpecs();
}
@@ -17,7 +17,7 @@ package com.jetbrains.python.testing.attest;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.util.io.FileUtil;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.testing.PythonTestCommandLineStateBase;
import java.util.ArrayList;
@@ -36,8 +36,8 @@ public class PythonAtTestCommandLineState extends PythonTestCommandLineStateBase
}
@Override
protected PythonHelpersLocator getRunner() {
return PythonHelpersLocator.ATTEST;
protected PythonHelper getRunner() {
return PythonHelper.ATTEST;
}
protected List<String> getTestSpecs() {
@@ -16,7 +16,7 @@
package com.jetbrains.python.testing.doctest;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.testing.PythonTestCommandLineStateBase;
import java.util.ArrayList;
@@ -35,8 +35,8 @@ public class PythonDocTestCommandLineState extends PythonTestCommandLineStateBas
}
@Override
protected PythonHelpersLocator getRunner() {
return PythonHelpersLocator.DOCSTRING;
protected PythonHelper getRunner() {
return PythonHelper.DOCSTRING;
}
protected List<String> getTestSpecs() {
@@ -20,7 +20,7 @@ import com.intellij.execution.configurations.ParamsGroup;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.testing.PythonTestCommandLineStateBase;
import java.util.ArrayList;
@@ -38,8 +38,8 @@ public class PythonNoseTestCommandLineState extends PythonTestCommandLineStateBa
}
@Override
protected PythonHelpersLocator getRunner() {
return PythonHelpersLocator.NOSE;
protected PythonHelper getRunner() {
return PythonHelper.NOSE;
}
protected List<String> getTestSpecs() {
@@ -24,8 +24,8 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.jetbrains.python.HelperPackage;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.testing.PythonTestCommandLineStateBase;
import org.jetbrains.annotations.NotNull;
@@ -51,8 +51,8 @@ public class PyTestCommandLineState extends PythonTestCommandLineStateBase {
}
@Override
protected PythonHelper getRunner() {
return PythonHelpersLocator.PYTEST;
protected HelperPackage getRunner() {
return PythonHelper.PYTEST;
}
@Override
@@ -15,14 +15,13 @@
*/
package com.jetbrains.python.testing.unittest;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.configurations.GeneralCommandLine;
import com.intellij.execution.configurations.ParamsGroup;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.jetbrains.python.PyNames;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.testing.AbstractPythonTestRunConfiguration;
import com.jetbrains.python.testing.PythonTestCommandLineStateBase;
@@ -43,11 +42,11 @@ public class PythonUnitTestCommandLineState extends
}
@Override
protected PythonHelpersLocator getRunner() {
protected PythonHelper getRunner() {
if (myConfig.getTestType() == AbstractPythonTestRunConfiguration.TestType.TEST_SCRIPT &&
myConfig.getScriptName().endsWith(PyNames.SETUP_DOT_PY))
return PythonHelpersLocator.SETUPPY;
return PythonHelpersLocator.UT;
return PythonHelper.SETUPPY;
return PythonHelper.UT;
}
protected List<String> getTestSpecs() {
@@ -50,11 +50,10 @@ import com.intellij.psi.PsiWhiteSpace;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Consumer;
import com.intellij.util.IncorrectOperationException;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.PythonLanguage;
import com.jetbrains.python.codeInsight.imports.OptimizeImportsQuickFix;
import com.jetbrains.python.formatter.PyCodeStyleSettings;
@@ -193,7 +192,7 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
options.add("--max-line-length=" + collectedInfo.margin);
options.add("-");
GeneralCommandLine cmd = PythonHelpersLocator.PEP8.newCommandLine(collectedInfo.interpreterPath, options);
GeneralCommandLine cmd = PythonHelper.PEP8.newCommandLine(collectedInfo.interpreterPath, options);
ProcessOutput output = PySdkUtil.getProcessOutput(cmd, new File(collectedInfo.interpreterPath).getParent(),
ImmutableMap.of("PYTHONBUFFERED", "1"),
@@ -24,7 +24,7 @@ import com.intellij.execution.executors.DefaultDebugExecutor;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.runners.ExecutionEnvironmentBuilder;
import com.intellij.openapi.project.Project;
import com.jetbrains.python.PythonHelpersLocator;
import com.jetbrains.python.PythonHelper;
import com.jetbrains.python.debugger.PyDebugRunner;
import com.jetbrains.python.run.AbstractPythonRunConfiguration;
import com.jetbrains.python.run.PythonCommandLineState;
@@ -41,7 +41,7 @@ public abstract class PyCommandLineTestCase extends PyTestCase {
protected static int verifyPyDevDParameters(List<String> params) {
params = Lists.newArrayList(params);
int debugParam = params.remove("--DEBUG") ? 1 : 0;
assertEquals(PythonHelpersLocator.DEBUGGER.asParamString(), params.get(0));
assertEquals(PythonHelper.DEBUGGER.asParamString(), params.get(0));
assertEquals("--multiproc", params.get(1));
assertEquals("--client", params.get(2));
assertEquals("--port", params.get(4));