-
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.
- Loading branch information
1 parent
89ad653
commit edc71b0
Showing
3 changed files
with
58 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
manifest.yml | ||
downloads/ | ||
downloads.tar.bz2 |
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,56 @@ | ||
#!/usr/bin/env python | ||
|
||
import argparse | ||
from glob import glob | ||
import json | ||
from os.path import join | ||
|
||
def activate_on_start(extension_path): | ||
package_json = join(extension_path, 'package.json') | ||
|
||
with open(package_json, 'rt') as f: | ||
pkg = json.load(f) | ||
|
||
## Python extension will activate when the editor loads | ||
pkg['activationEvents'].insert(0, 'workspaceContains:**/anaconda-project.yml') | ||
|
||
with open(package_json, 'wt') as f: | ||
json.dump(pkg, f) | ||
|
||
|
||
def preparing_env(extension_path): | ||
## Indicate that environment is being prepared | ||
source = join(extension_path, 'out', 'client', 'extension.js') | ||
|
||
with open(source, 'rt') as f: | ||
js = f.read() | ||
|
||
js = js.replace(' Select Python Interpreter', ' Preparing Environment...') | ||
|
||
with open(source, 'wt') as f: | ||
f.write(js) | ||
|
||
|
||
def cli(): | ||
parser = argparse.ArgumentParser(description='Patch the VSCode Python extension.') | ||
|
||
parser.add_argument('extension_path', help='Path to the installed Python extension.') | ||
|
||
parser.add_argument('--auto-start', help='Force the Python extension to start when the session loads.', | ||
action='store_true') | ||
parser.add_argument('--preparing-env', help='Indicate that the environment is being prepared if not found.', | ||
action='store_true') | ||
|
||
return parser | ||
|
||
def main(args): | ||
if args.auto_start: | ||
activate_on_start(args.extension_path) | ||
|
||
if args.preparing_env: | ||
preparing_env(args.extension_path) | ||
|
||
if __name__ == '__main__': | ||
args = cli().parse_args() | ||
|
||
main(args) |
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