Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py

changeset 6331
758b1cb7a2e6
parent 6301
f488d2cc5841
child 6334
ca90aee56d20
diff -r f2674335cf69 -r 758b1cb7a2e6 Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py
--- a/Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py	Fri Jun 08 19:07:18 2018 +0200
+++ b/Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py	Fri Jun 08 19:24:24 2018 +0200
@@ -26,7 +26,6 @@
 from . import DefaultIndexUrlXml
 
 
-# TODO: add support for --user; additional button
 class PipSearchDialog(QDialog, Ui_PipSearchDialog):
     """
     Class implementing a dialog to search PyPI.
@@ -59,6 +58,10 @@
             self.tr("&Install"), QDialogButtonBox.ActionRole)
         self.__installButton.setEnabled(False)
         
+        self.__installUserButton = self.buttonBox.addButton(
+            self.tr("Install to &User-Site"), QDialogButtonBox.ActionRole)
+        self.__installUserButton.setEnabled(False)
+        
         self.__showDetailsButton = self.buttonBox.addButton(
             self.tr("&Show Details..."), QDialogButtonBox.ActionRole)
         self.__showDetailsButton.setEnabled(False)
@@ -119,6 +122,8 @@
         """
         self.__installButton.setEnabled(
             len(self.resultList.selectedItems()) > 0)
+        self.__installUserButton.setEnabled(
+            len(self.resultList.selectedItems()) > 0)
         self.__showDetailsButton.setEnabled(
             len(self.resultList.selectedItems()) == 1)
     
@@ -136,6 +141,8 @@
             self.__canceled = True
         elif button == self.__installButton:
             self.__install()
+        elif button == self.__installUserButton:
+            self.__install(userSite=True)
         elif button == self.__showDetailsButton:
             self.__showDetails()
     
@@ -321,10 +328,12 @@
         
         return score
     
-    # TODO: add support for --user
-    def __install(self):
+    def __install(self,  userSite=False):
         """
         Private slot to install the selected packages.
+        
+        @param userSite flag indicating to install to the user directory
+        @type bool
         """
         command = self.pipComboBox.currentText()
         if command == self.__default:
@@ -334,7 +343,8 @@
         for itm in self.resultList.selectedItems():
             packages.append(itm.text(0).strip())
         if packages:
-            self.__pip.installPackages(packages, cmd=command)
+            self.__pip.installPackages(packages, cmd=command,
+                                       userSite=userSite)
     
     def __showDetails(self):
         """

eric ide

mercurial