forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds low-level locators (microsoft#14655)
* Provide factory function for posix locator * Provide factory function for global virtual env * Provide factory function for windos store and reg * Refactor and add low-level locators * Tweak interfaces * clean up * Simplify disposing locators * Ignore dispose fails after logging * Rebase with main and fix conflicts
- Loading branch information
1 parent
7b275b4
commit 0d398f7
Showing
23 changed files
with
343 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { PythonEnvInfo } from './info'; | ||
import { | ||
ILocator, | ||
IPythonEnvsIterator, | ||
NOOP_ITERATOR, | ||
PythonLocatorQuery, | ||
} from './locator'; | ||
import { DisableableEnvsWatcher } from './watchers'; | ||
|
||
/** | ||
* A locator wrapper that can be disabled. | ||
* | ||
* If disabled, events emitted by the wrapped locator are discarded, | ||
* `iterEnvs()` yields nothing, and `resolveEnv()` already returns | ||
* `undefined`. | ||
*/ | ||
export class DisableableLocator extends DisableableEnvsWatcher implements ILocator { | ||
constructor( | ||
// To wrapp more than one use `Locators`. | ||
private readonly locator: ILocator, | ||
) { | ||
super(locator); | ||
} | ||
|
||
public iterEnvs(query?: PythonLocatorQuery): IPythonEnvsIterator { | ||
if (!this.enabled) { | ||
return NOOP_ITERATOR; | ||
} | ||
return this.locator.iterEnvs(query); | ||
} | ||
|
||
public async resolveEnv(env: string | PythonEnvInfo): Promise<PythonEnvInfo | undefined> { | ||
if (!this.enabled) { | ||
return undefined; | ||
} | ||
return this.locator.resolveEnv(env); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.