forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.ts
More file actions
47 lines (38 loc) · 1.52 KB
/
api.ts
File metadata and controls
47 lines (38 loc) · 1.52 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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import { Event } from 'vscode';
import { Disposables, IDisposable } from '../common/utils/resourceLifecycle';
import { PythonEnvInfo } from './base/info';
import { ILocator, IPythonEnvsIterator, PythonLocatorQuery } from './base/locator';
import { GetLocatorFunc, LazyWrappingLocator } from './base/locators/common/wrappingLocator';
import { PythonEnvsChangedEvent } from './base/watcher';
/**
* The public API for the Python environments component.
*
* Note that this is composed of sub-components.
*/
export class PythonEnvironments implements ILocator, IDisposable {
private readonly disposables = new Disposables();
private readonly locators: ILocator;
constructor(
// These are factories for the sub-components the full component is composed of:
getLocators: GetLocatorFunc,
) {
const locators = new LazyWrappingLocator(getLocators);
this.locators = locators;
this.disposables.push(locators);
}
public async dispose(): Promise<void> {
await this.disposables.dispose();
}
// For ILocator:
public get onChanged(): Event<PythonEnvsChangedEvent> {
return this.locators.onChanged;
}
public iterEnvs(query?: PythonLocatorQuery): IPythonEnvsIterator {
return this.locators.iterEnvs(query);
}
public async resolveEnv(env: string | PythonEnvInfo): Promise<PythonEnvInfo | undefined> {
return this.locators.resolveEnv(env);
}
}