Plugins/UiExtensionPlugins/PipInterface/PipListDialog.py

changeset 6327
a1716d9210f4
parent 6301
f488d2cc5841
child 6342
c79ecba9cde7
equal deleted inserted replaced
6326:5ef9456a0cbe 6327:a1716d9210f4
24 from .Ui_PipListDialog import Ui_PipListDialog 24 from .Ui_PipListDialog import Ui_PipListDialog
25 25
26 import Preferences 26 import Preferences
27 27
28 28
29 # TODO: add support for --user (User Site only)
30 class PipListDialog(QDialog, Ui_PipListDialog): 29 class PipListDialog(QDialog, Ui_PipListDialog):
31 """ 30 """
32 Class implementing a dialog to list installed packages. 31 Class implementing a dialog to list installed packages.
33 """ 32 """
34 CommandArguments = { 33 CommandArguments = {
269 args = PipListDialog.CommandArguments[self.__mode][:] 268 args = PipListDialog.CommandArguments[self.__mode][:]
270 if self.localCheckBox.isChecked(): 269 if self.localCheckBox.isChecked():
271 args.append("--local") 270 args.append("--local")
272 if self.notRequiredCheckBox.isChecked(): 271 if self.notRequiredCheckBox.isChecked():
273 args.append("--not-required") 272 args.append("--not-required")
273 if self.userCheckBox.isChecked():
274 args.append("--user")
274 275
275 if self.__indexUrl: 276 if self.__indexUrl:
276 args.append("--index-url") 277 args.append("--index-url")
277 args.append(self.__indexUrl + "/simple") 278 args.append(self.__indexUrl + "/simple")
278 279
348 @pyqtSlot(bool) 349 @pyqtSlot(bool)
349 def on_localCheckBox_clicked(self, checked): 350 def on_localCheckBox_clicked(self, checked):
350 """ 351 """
351 Private slot handling the switching of the local mode. 352 Private slot handling the switching of the local mode.
352 353
353 @param checked state of the local check box (boolean) 354 @param checked state of the local check box
355 @type bool
354 """ 356 """
355 self.__refresh() 357 self.__refresh()
356 358
357 @pyqtSlot(bool) 359 @pyqtSlot(bool)
358 def on_notRequiredCheckBox_clicked(self, checked): 360 def on_notRequiredCheckBox_clicked(self, checked):
359 """ 361 """
360 Private slot handling the switching of the 'not required' mode. 362 Private slot handling the switching of the 'not required' mode.
361 363
362 @param checked state of the 'not required' check box (boolean) 364 @param checked state of the 'not required' check box
365 @type bool
366 """
367 self.__refresh()
368
369 @pyqtSlot(bool)
370 def on_userCheckBox_clicked(self, checked):
371 """
372 Private slot handling the switching of the 'user-site' mode.
373
374 @param checked state of the 'user-site' check box
375 @type bool
363 """ 376 """
364 self.__refresh() 377 self.__refresh()
365 378
366 @pyqtSlot() 379 @pyqtSlot()
367 def on_packageList_itemSelectionChanged(self): 380 def on_packageList_itemSelectionChanged(self):
453 @param checked state of the checkbox 466 @param checked state of the checkbox
454 @type bool 467 @type bool
455 """ 468 """
456 self.on_packageList_itemSelectionChanged() 469 self.on_packageList_itemSelectionChanged()
457 470
458 # TODO: add support for --user
459 def __upgradePackages(self): 471 def __upgradePackages(self):
460 """ 472 """
461 Private slot to upgrade the selected packages. 473 Private slot to upgrade the selected packages.
462 """ 474 """
463 packages = [] 475 packages = []
468 if "pip" in packages: 480 if "pip" in packages:
469 self.__upgradePip() 481 self.__upgradePip()
470 else: 482 else:
471 self.__executeUpgradePackages(packages) 483 self.__executeUpgradePackages(packages)
472 484
473 # TODO: add support for --user
474 def __upgradeAllPackages(self): 485 def __upgradeAllPackages(self):
475 """ 486 """
476 Private slot to upgrade all listed packages. 487 Private slot to upgrade all listed packages.
477 """ 488 """
478 packages = [] 489 packages = []
484 if "pip" in packages: 495 if "pip" in packages:
485 self.__upgradePip() 496 self.__upgradePip()
486 else: 497 else:
487 self.__executeUpgradePackages(packages) 498 self.__executeUpgradePackages(packages)
488 499
489 # TODO: add support for --user
490 def __upgradePip(self): 500 def __upgradePip(self):
491 """ 501 """
492 Private slot to upgrade pip itself. 502 Private slot to upgrade pip itself.
493 """ 503 """
494 pip = self.pipComboBox.currentText() 504 pip = self.pipComboBox.currentText()
495 if pip == self.__default: 505 if pip == self.__default:
496 pip = "" 506 pip = ""
497 507
498 res = self.__pip.upgradePip(pip=pip) 508 res = self.__pip.upgradePip(
509 pip=pip, userSite=self.userCheckBox.isChecked())
499 if res: 510 if res:
500 self.__refresh() 511 self.__refresh()
501 512
502 # TODO: add support for --user
503 def __executeUpgradePackages(self, packages): 513 def __executeUpgradePackages(self, packages):
504 """ 514 """
505 Private method to execute the pip upgrade command. 515 Private method to execute the pip upgrade command.
506 516
507 @param packages list of package names to be upgraded 517 @param packages list of package names to be upgraded
509 """ 519 """
510 command = self.pipComboBox.currentText() 520 command = self.pipComboBox.currentText()
511 if command == self.__default: 521 if command == self.__default:
512 command = "" 522 command = ""
513 523
514 res = self.__pip.upgradePackages(packages, cmd=command) 524 res = self.__pip.upgradePackages(
525 packages, cmd=command, userSite=self.userCheckBox.isChecked())
515 if res: 526 if res:
516 self.__refresh() 527 self.__refresh()
517 528
518 def __uninstallPackages(self): 529 def __uninstallPackages(self):
519 """ 530 """

eric ide

mercurial