forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmockJupyterNotebook.ts
More file actions
108 lines (91 loc) · 3.68 KB
/
Copy pathmockJupyterNotebook.ts
File metadata and controls
108 lines (91 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { JSONObject } from '@phosphor/coreutils/lib/json';
import { Observable } from 'rxjs/Observable';
import { CancellationToken, Event, EventEmitter, Uri } from 'vscode';
import { Identifiers } from '../../client/datascience/constants';
import { LiveKernelModel } from '../../client/datascience/jupyter/kernels/types';
import { ICell, IJupyterKernelSpec, INotebook, INotebookCompletion, INotebookExecutionLogger, INotebookServer, InterruptResult } from '../../client/datascience/types';
import { PythonInterpreter } from '../../client/interpreter/contracts';
import { ServerStatus } from '../../datascience-ui/interactive-common/mainState';
import { noop } from '../core';
export class MockJupyterNotebook implements INotebook {
public onKernelChanged: Event<IJupyterKernelSpec | LiveKernelModel> = new EventEmitter<IJupyterKernelSpec | LiveKernelModel>().event;
private onStatusChangedEvent: EventEmitter<ServerStatus> | undefined;
constructor(private owner: INotebookServer) {
noop();
}
public get server(): INotebookServer {
return this.owner;
}
public get resource(): Uri {
return Uri.parse(Identifiers.InteractiveWindowIdentity);
}
public clear(_id: string): void {
noop();
}
public executeObservable(_code: string, _f: string, _line: number): Observable<ICell[]> {
throw new Error('Method not implemented');
}
public inspect(_code: string, _cancelToken?: CancellationToken): Promise<JSONObject> {
return Promise.resolve({});
}
public async getCompletion(_cellCode: string, _offsetInCode: number, _cancelToken?: CancellationToken): Promise<INotebookCompletion> {
throw new Error('Method not implemented');
}
public execute(_code: string, _f: string, _line: number): Promise<ICell[]> {
throw new Error('Method not implemented');
}
public restartKernel(): Promise<void> {
throw new Error('Method not implemented');
}
public translateToNotebook(_cells: ICell[]): Promise<JSONObject> {
throw new Error('Method not implemented');
}
public waitForIdle(): Promise<void> {
throw new Error('Method not implemented');
}
public setLaunchingFile(_file: string): Promise<void> {
throw new Error('Method not implemented');
}
public async setMatplotLibStyle(_useDark: boolean): Promise<void> {
noop();
}
public addLogger(_logger: INotebookExecutionLogger): void {
noop();
}
public getSysInfo(): Promise<ICell | undefined> {
return Promise.resolve(undefined);
}
public interruptKernel(_timeout: number): Promise<InterruptResult> {
throw new Error('Method not implemented');
}
public async dispose(): Promise<void> {
if (this.onStatusChangedEvent) {
this.onStatusChangedEvent.dispose();
}
return Promise.resolve();
}
public getMatchingInterpreter(): PythonInterpreter | undefined {
return;
}
public setInterpreter(_inter: PythonInterpreter) {
noop();
}
public getKernelSpec(): IJupyterKernelSpec | undefined {
return;
}
public setKernelSpec(_spec: IJupyterKernelSpec | LiveKernelModel, _timeout: number): Promise<void> {
return Promise.resolve();
}
public get onSessionStatusChanged(): Event<ServerStatus> {
if (!this.onStatusChangedEvent) {
this.onStatusChangedEvent = new EventEmitter<ServerStatus>();
}
return this.onStatusChangedEvent.event;
}
public get status(): ServerStatus {
return ServerStatus.Idle;
}
}