Skip to content

Commit c6da5fd

Browse files
Add a basic collection of env locators.
1 parent 5590027 commit c6da5fd

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
import { chain } from '../../common/utils/async';
5+
import { PythonEnvInfo } from './info';
6+
import { ILocator, PythonEnvsIterator, PythonLocatorQuery } from './locator';
7+
import { PythonEnvsWatchers } from './watchers';
8+
9+
/**
10+
* A wrapper around a set of locators.
11+
*
12+
* Events and iterator results are combined.
13+
*/
14+
export class Locators extends PythonEnvsWatchers {
15+
constructor(
16+
// The locators will be watched as well as iterated.
17+
private readonly locators: ReadonlyArray<ILocator>
18+
) {
19+
super(locators);
20+
}
21+
22+
public iterEnvs(query?: PythonLocatorQuery): PythonEnvsIterator {
23+
const iterators = this.locators.map((loc) => loc.iterEnvs(query));
24+
return chain<PythonEnvInfo>(iterators);
25+
}
26+
}

0 commit comments

Comments
 (0)