Search in sources :

Example 1 with AddImportStatus

use of com.twosigma.beakerx.kernel.AddImportStatus in project beakerx by twosigma.

the class AddImportMagicCommand method execute.

@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
    String command = param.getCommand();
    String[] parts = MagicCommandUtils.splitPath(command);
    if (parts.length != 2) {
        return new MagicCommandOutput(ERROR, WRONG_FORMAT_MSG + IMPORT);
    }
    ImportPath anImport = new ImportPath(parts[1]);
    AddImportStatus status = this.kernel.addImport(anImport);
    if (AddImportStatus.ERROR.equals(status)) {
        return new MagicCommandOutput(ERROR, "Could not import " + parts[1]);
    }
    return new MagicCommandOutput(OK);
}
Also used : AddImportStatus(com.twosigma.beakerx.kernel.AddImportStatus) MagicCommandOutput(com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput) ImportPath(com.twosigma.beakerx.kernel.ImportPath)

Example 2 with AddImportStatus

use of com.twosigma.beakerx.kernel.AddImportStatus in project beakerx by twosigma.

the class AddStaticImportMagicCommand method execute.

@Override
public MagicCommandOutcomeItem execute(MagicCommandExecutionParam param) {
    String command = param.getCommand();
    String[] parts = MagicCommandUtils.splitPath(command);
    if (parts.length != 3) {
        return new MagicCommandOutput(MagicCommandOutput.Status.ERROR, WRONG_FORMAT_MSG);
    }
    AddImportStatus status = this.kernel.addImport(new ImportPath(parts[1] + " " + parts[2]));
    if (AddImportStatus.ERROR.equals(status)) {
        return new MagicCommandOutput(ERROR, "Could not import static " + parts[2]);
    }
    return new MagicCommandOutput(MagicCommandOutput.Status.OK);
}
Also used : AddImportStatus(com.twosigma.beakerx.kernel.AddImportStatus) MagicCommandOutput(com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput) ImportPath(com.twosigma.beakerx.kernel.ImportPath)

Aggregations

AddImportStatus (com.twosigma.beakerx.kernel.AddImportStatus)2 ImportPath (com.twosigma.beakerx.kernel.ImportPath)2 MagicCommandOutput (com.twosigma.beakerx.kernel.magic.command.outcome.MagicCommandOutput)2