@@ -34,13 +34,31 @@ ProductInstallScripts.set(Product.pylint, ['-m', 'pip', 'install', 'pylint']);
3434ProductInstallScripts . set ( Product . pytest ,  [ '-m' ,  'pip' ,  'install' ,  '-U' ,  'pytest' ] ) ; 
3535ProductInstallScripts . set ( Product . yapf ,  [ '-m' ,  'pip' ,  'install' ,  'yapf' ] ) ; 
3636
37- export  const  ProductExecutableAndArgs  =  new  Map < Product ,  { executable : string ,  args : string [ ] } > ( ) ; 
38- ProductExecutableAndArgs . set ( Product . mypy ,  { executable : 'python' ,  args :[ '-m' ,  'mypy' ] } ) ; 
39- ProductExecutableAndArgs . set ( Product . nosetest ,  { executable : 'python' ,  args :[ '-m' ,  'nose' ] } ) ; 
40- ProductExecutableAndArgs . set ( Product . pylama ,  { executable : 'python' ,  args :[ '-m' ,  'pylama' ] } ) ; 
41- ProductExecutableAndArgs . set ( Product . prospector ,  { executable : 'python' ,  args :[ '-m' ,  'prospector' ] } ) ; 
42- ProductExecutableAndArgs . set ( Product . pylint ,  { executable : 'python' ,  args :[ '-m' ,  'pylint' ] } ) ; 
43- ProductExecutableAndArgs . set ( Product . pytest ,  { executable : 'python' ,  args :[ '-m' ,  'pytest' ] } ) ; 
37+ const  ProductUninstallScripts  =  new  Map < Product ,  string [ ] > ( ) ; 
38+ ProductUninstallScripts . set ( Product . autopep8 ,  [ '-m' ,  'pip' ,  'uninstall' ,  'autopep8' ,  '--yes' ] ) ; 
39+ ProductUninstallScripts . set ( Product . flake8 ,  [ '-m' ,  'pip' ,  'uninstall' ,  'flake8' ,  '--yes' ] ) ; 
40+ ProductUninstallScripts . set ( Product . mypy ,  [ '-m' ,  'pip' ,  'uninstall' ,  'mypy' ,  '--yes' ] ) ; 
41+ ProductUninstallScripts . set ( Product . nosetest ,  [ '-m' ,  'pip' ,  'uninstall' ,  'nose' ,  '--yes' ] ) ; 
42+ ProductUninstallScripts . set ( Product . pep8 ,  [ '-m' ,  'pip' ,  'uninstall' ,  'pep8' ,  '--yes' ] ) ; 
43+ ProductUninstallScripts . set ( Product . pylama ,  [ '-m' ,  'pip' ,  'uninstall' ,  'pylama' ,  '--yes' ] ) ; 
44+ ProductUninstallScripts . set ( Product . prospector ,  [ '-m' ,  'pip' ,  'uninstall' ,  'prospector' ,  '--yes' ] ) ; 
45+ ProductUninstallScripts . set ( Product . pydocstyle ,  [ '-m' ,  'pip' ,  'uninstall' ,  'pydocstyle' ,  '--yes' ] ) ; 
46+ ProductUninstallScripts . set ( Product . pylint ,  [ '-m' ,  'pip' ,  'uninstall' ,  'pylint' ,  '--yes' ] ) ; 
47+ ProductUninstallScripts . set ( Product . pytest ,  [ '-m' ,  'pip' ,  'uninstall' ,  'pytest' ,  '--yes' ] ) ; 
48+ ProductUninstallScripts . set ( Product . yapf ,  [ '-m' ,  'pip' ,  'uninstall' ,  'yapf' ,  '--yes' ] ) ; 
49+ 
50+ export  const  ProductExecutableAndArgs  =  new  Map < Product ,  {  executable : string ,  args : string [ ]  } > ( ) ; 
51+ ProductExecutableAndArgs . set ( Product . mypy ,  {  executable : 'python' ,  args : [ '-m' ,  'mypy' ]  } ) ; 
52+ ProductExecutableAndArgs . set ( Product . nosetest ,  {  executable : 'python' ,  args : [ '-m' ,  'nose' ]  } ) ; 
53+ ProductExecutableAndArgs . set ( Product . pylama ,  {  executable : 'python' ,  args : [ '-m' ,  'pylama' ]  } ) ; 
54+ ProductExecutableAndArgs . set ( Product . prospector ,  {  executable : 'python' ,  args : [ '-m' ,  'prospector' ]  } ) ; 
55+ ProductExecutableAndArgs . set ( Product . pylint ,  {  executable : 'python' ,  args : [ '-m' ,  'pylint' ]  } ) ; 
56+ ProductExecutableAndArgs . set ( Product . pytest ,  {  executable : 'python' ,  args : [ '-m' ,  'pytest' ]  } ) ; 
57+ ProductExecutableAndArgs . set ( Product . autopep8 ,  {  executable : 'python' ,  args : [ '-m' ,  'autopep8' ]  } ) ; 
58+ ProductExecutableAndArgs . set ( Product . pep8 ,  {  executable : 'python' ,  args : [ '-m' ,  'pep8' ]  } ) ; 
59+ ProductExecutableAndArgs . set ( Product . pydocstyle ,  {  executable : 'python' ,  args : [ '-m' ,  'pydocstyle' ]  } ) ; 
60+ ProductExecutableAndArgs . set ( Product . yapf ,  {  executable : 'python' ,  args : [ '-m' ,  'yapf' ]  } ) ; 
61+ ProductExecutableAndArgs . set ( Product . flake8 ,  {  executable : 'python' ,  args : [ '-m' ,  'flake8' ]  } ) ; 
4462
4563switch  ( os . platform ( ) )  { 
4664 case  'win32' : { 
@@ -72,8 +90,7 @@ ProductNames.set(Product.pylint, 'pylint');
7290ProductNames . set ( Product . pytest ,  'py.test' ) ; 
7391ProductNames . set ( Product . yapf ,  'yapf' ) ; 
7492
75- const  SettingToDisableProduct  =  new  Map < Product ,  string > ( ) ; 
76- SettingToDisableProduct . set ( Product . autopep8 ,  'autopep8' ) ; 
93+ export  const  SettingToDisableProduct  =  new  Map < Product ,  string > ( ) ; 
7794SettingToDisableProduct . set ( Product . flake8 ,  'linting.flake8Enabled' ) ; 
7895SettingToDisableProduct . set ( Product . mypy ,  'linting.mypyEnabled' ) ; 
7996SettingToDisableProduct . set ( Product . nosetest ,  'unitTest.nosetestsEnabled' ) ; 
@@ -83,7 +100,6 @@ SettingToDisableProduct.set(Product.prospector, 'linting.prospectorEnabled');
83100SettingToDisableProduct . set ( Product . pydocstyle ,  'linting.pydocstyleEnabled' ) ; 
84101SettingToDisableProduct . set ( Product . pylint ,  'linting.pylintEnabled' ) ; 
85102SettingToDisableProduct . set ( Product . pytest ,  'unitTest.pyTestEnabled' ) ; 
86- SettingToDisableProduct . set ( Product . yapf ,  'yapf' ) ; 
87103
88104export  class  Installer  { 
89105 private  static  terminal : vscode . Terminal ; 
@@ -117,7 +133,7 @@ export class Installer {
117133 return  vscode . window . showErrorMessage ( `${ productType } ${ productName }  ,  ...options ) . then ( item  =>  { 
118134 switch  ( item )  { 
119135 case  installOption : { 
120-  return  this . installProduct ( product ) ; 
136+  return  this . install ( product ) ; 
121137 } 
122138 case  disableOption : { 
123139 if  ( Linters . indexOf ( product )  >=  0 )  { 
@@ -140,7 +156,7 @@ export class Installer {
140156 } ) ; 
141157 } 
142158
143-  installProduct ( product : Product ) : Promise < any >  { 
159+  install ( product : Product ) : Promise < any >  { 
144160 if  ( ! this . outputChannel  &&  ! Installer . terminal )  { 
145161 Installer . terminal  =  vscode . window . createTerminal ( 'Python Installer' ) ; 
146162 } 
@@ -190,9 +206,13 @@ export class Installer {
190206 } 
191207 } 
192208
193-  isProductInstalled ( product : Product ) : Promise < boolean >  { 
209+  isInstalled ( product : Product ) : Promise < boolean >  { 
194210 return  isProductInstalled ( product ) ; 
195211 } 
212+ 
213+  uninstall ( product : Product ) : Promise < any >  { 
214+  return  uninstallproduct ( product ) ; 
215+  } 
196216} 
197217
198218export  function  disableLinter ( product : Product )  { 
@@ -206,30 +226,17 @@ export function disableLinter(product: Product) {
206226 } 
207227} 
208228
209- function  isTestFrameworkInstalled ( product : Product ) : Promise < boolean >  { 
210-  const  fileToRun  =  product  ===  Product . pytest  ? 'py.test'  : 'nosetests' ; 
211-  const  def  =  createDeferred < boolean > ( ) ; 
212-  execPythonFile ( fileToRun ,  [ '--version' ] ,  vscode . workspace . rootPath ,  false ) 
229+ function  isProductInstalled ( product : Product ) : Promise < boolean >  { 
230+  const  prodExec  =  ProductExecutableAndArgs . get ( product ) ; 
231+  return  execPythonFile ( prodExec . executable ,  prodExec . args . concat ( [ '--version' ] ) ,  vscode . workspace . rootPath ,  false ,  undefined ,  undefined ,  true ) 
213232 . then ( ( )  =>  { 
214-  def . resolve ( true ) ; 
233+  return   true ; 
215234 } ) . catch ( reason  =>  { 
216-  if  ( isNotInstalledError ( reason ) )  { 
217-  def . resolve ( false ) ; 
218-  } 
219-  else  { 
220-  def . resolve ( true ) ; 
221-  } 
235+  return  ! isNotInstalledError ( reason ) ; 
222236 } ) ; 
223-  return  def . promise ; 
224237} 
225- function  isProductInstalled ( product : Product ) : Promise < boolean >  { 
226-  switch  ( product )  { 
227-  case  Product . pytest : { 
228-  return  isTestFrameworkInstalled ( product ) ; 
229-  } 
230-  case  Product . nosetest : { 
231-  return  isTestFrameworkInstalled ( product ) ; 
232-  } 
233-  } 
234-  throw  new  Error ( 'Not supported' ) ; 
238+ 
239+ function  uninstallproduct ( product : Product ) : Promise < any >  { 
240+  const  uninstallArgs  =  ProductUninstallScripts . get ( product ) ; 
241+  return  execPythonFile ( 'python' ,  uninstallArgs ,  vscode . workspace . rootPath ,  false ,  undefined ,  undefined ,  true ) ; 
235242} 
0 commit comments