diff -r a00e63f6d766 -r c79ecba9cde7 Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py --- a/Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py Tue Jun 12 18:59:45 2018 +0200 +++ b/Plugins/UiExtensionPlugins/PipInterface/PipSearchDialog.py Tue Jun 12 19:01:06 2018 +0200 @@ -23,8 +23,6 @@ from .Ui_PipSearchDialog import Ui_PipSearchDialog -from . import DefaultIndexUrlXml - class PipSearchDialog(QDialog, Ui_PipSearchDialog): """ @@ -40,13 +38,16 @@ "they", "this", "to", "was", "will", } - def __init__(self, pip, plugin, parent=None): + def __init__(self, pip, indexUrl, parent=None): """ Constructor - @param pip reference to the master object (Pip) - @param plugin reference to the plugin object (ToolPipPlugin) - @param parent reference to the parent widget (QWidget) + @param pip reference to the master object + @type Pip + @param indexUrl URL of XML RPC interface to the pypi index + @type str + @param parent reference to the parent widget + @type QWidget """ super(PipSearchDialog, self).__init__(parent) self.setupUi(self) @@ -67,16 +68,10 @@ self.__showDetailsButton.setEnabled(False) self.__pip = pip - if plugin.getPreferences("PipSearchIndex"): - indexUrl = plugin.getPreferences("PipSearchIndex") + "/pypi" - else: - indexUrl = DefaultIndexUrlXml self.__client = E5XmlRpcClient(indexUrl, self) - self.__default = self.tr("<Default>") - pipExecutables = sorted(plugin.getPreferences("PipExecutables")) - self.pipComboBox.addItem(self.__default) - self.pipComboBox.addItems(pipExecutables) + self.venvComboBox.addItem(self.__pip.getDefaultEnvironmentString()) + self.venvComboBox.addItems(self.__pip.getVirtualenvNames()) self.searchEdit.setFocus(Qt.OtherFocusReason) @@ -90,7 +85,8 @@ """ Protected slot implementing a close event handler. - @param e close event (QCloseEvent) + @param e close event + @type QCloseEvent """ QApplication.restoreOverrideCursor() @@ -104,7 +100,8 @@ """ Private slot handling a change of the search term. - @param txt search term (string) + @param txt search term + @type str """ self.searchButton.setEnabled(bool(txt)) @@ -132,7 +129,8 @@ """ Private slot called by a button of the button box clicked. - @param button button that was clicked (QAbstractButton) + @param button button that was clicked + @type QAbstractButton """ if button == self.buttonBox.button(QDialogButtonBox.Close): self.close() @@ -177,7 +175,8 @@ """ Private method to process the search result data from PyPI. - @param data result data (tuple) with hits in the first element + @param data result data with hits in the first element + @type tuple """ if data: packages = self.__transformHits(data[0]) @@ -256,8 +255,10 @@ """ Private method handling a search error. - @param errorCode code of the error (integer) - @param errorString error message (string) + @param errorCode code of the error + @type int + @param errorString error message + @type str """ self.__finish() E5MessageBox.warning( @@ -272,8 +273,10 @@ Private method to convert the list returned from pypi into a packages list. - @param hits list returned from pypi (list of dict) - @return list of packages (list of dict) + @param hits list returned from pypi + @type list of dict + @return list of packages + @rtype list of dict """ # we only include the record with the highest score packages = {} @@ -335,15 +338,13 @@ @param userSite flag indicating to install to the user directory @type bool """ - command = self.pipComboBox.currentText() - if command == self.__default: - command = "" + venvName = self.venvComboBox.currentText() packages = [] for itm in self.resultList.selectedItems(): packages.append(itm.text(0).strip()) if packages: - self.__pip.installPackages(packages, cmd=command, + self.__pip.installPackages(packages, venvName=venvName, userSite=userSite) def __showDetails(self): @@ -415,8 +416,8 @@ """ Private method to display the returned package details. - @param data result data (tuple) with downloads information in the first - element + @param data result data with downloads information in the first element + @type tuple """ from .PipPackageDetailsDialog import PipPackageDetailsDialog @@ -434,8 +435,10 @@ """ Private method handling a details error. - @param errorCode code of the error (integer) - @param errorString error message (string) + @param errorCode code of the error + @type int + @param errorString error message + @type str """ self.__finish() self.__showDetailsButton.setEnabled(True) @@ -451,7 +454,9 @@ """ Private slot reacting on an item activation. - @param item reference to the activated item (QTreeWidgetItem) - @param column activated column (integer) + @param item reference to the activated item + @type QTreeWidgetItem + @param column activated column + @type int """ self.__showDetails()