147 @rtype list of dict |
148 @rtype list of dict |
148 """ |
149 """ |
149 return self.__results |
150 return self.__results |
150 |
151 |
151 |
152 |
|
153 class PipPackageInformationMode(enum.Enum): |
|
154 """ |
|
155 Class defining the show information process modes. |
|
156 """ |
|
157 |
|
158 General = 0 |
|
159 Classifiers = 1 |
|
160 EntryPoints = 2 |
|
161 FilesList = 3 |
|
162 UrlsList = 4 |
|
163 |
|
164 |
152 class PipPackagesWidget(QWidget, Ui_PipPackagesWidget): |
165 class PipPackagesWidget(QWidget, Ui_PipPackagesWidget): |
153 """ |
166 """ |
154 Class implementing the pip packages management widget. |
167 Class implementing the pip packages management widget. |
155 """ |
168 """ |
156 |
|
157 ShowProcessGeneralMode = 0 |
|
158 ShowProcessClassifiersMode = 1 |
|
159 ShowProcessEntryPointsMode = 2 |
|
160 ShowProcessFilesListMode = 3 |
|
161 ShowProcessUrlsListMode = 4 |
|
162 |
169 |
163 SearchVersionRole = Qt.ItemDataRole.UserRole + 1 |
170 SearchVersionRole = Qt.ItemDataRole.UserRole + 1 |
164 VulnerabilityRole = Qt.ItemDataRole.UserRole + 2 |
171 VulnerabilityRole = Qt.ItemDataRole.UserRole + 2 |
165 |
172 |
166 PackageColumn = 0 |
173 PackageColumn = 0 |
583 |
590 |
584 with EricOverrideCursor(): |
591 with EricOverrideCursor(): |
585 success, output = self.__pip.runProcess(args, interpreter) |
592 success, output = self.__pip.runProcess(args, interpreter) |
586 |
593 |
587 if success and output: |
594 if success and output: |
588 mode = self.ShowProcessGeneralMode |
595 mode = PipPackageInformationMode.General |
589 for line in output.splitlines(): |
596 for line in output.splitlines(): |
590 line = line.rstrip() |
597 line = line.rstrip() |
591 if line and line != "---": |
598 if line and line != "---": |
592 if mode != self.ShowProcessGeneralMode: |
599 if mode != PipPackageInformationMode.General: |
593 if line[0] == " ": |
600 if line[0] == " ": |
594 QTreeWidgetItem(infoWidget, [" ", line.strip()]) |
601 QTreeWidgetItem(infoWidget, [" ", line.strip()]) |
595 else: |
602 else: |
596 mode = self.ShowProcessGeneralMode |
603 mode = PipPackageInformationMode.General |
597 if mode == self.ShowProcessGeneralMode: |
604 if mode == PipPackageInformationMode.General: |
598 try: |
605 try: |
599 label, info = line.split(": ", 1) |
606 label, info = line.split(": ", 1) |
600 except ValueError: |
607 except ValueError: |
601 label = line[:-1] |
608 label = line[:-1] |
602 info = "" |
609 info = "" |
604 if label in self.__infoLabels: |
611 if label in self.__infoLabels: |
605 QTreeWidgetItem( |
612 QTreeWidgetItem( |
606 infoWidget, [self.__infoLabels[label], info] |
613 infoWidget, [self.__infoLabels[label], info] |
607 ) |
614 ) |
608 if label == "files": |
615 if label == "files": |
609 mode = self.ShowProcessFilesListMode |
616 mode = PipPackageInformationMode.FilesList |
610 elif label == "classifiers": |
617 elif label == "classifiers": |
611 mode = self.ShowProcessClassifiersMode |
618 mode = PipPackageInformationMode.Classifiers |
612 elif label == "entry-points": |
619 elif label == "entry-points": |
613 mode = self.ShowProcessEntryPointsMode |
620 mode = PipPackageInformationMode.EntryPoints |
614 elif label == "project-urls": |
621 elif label == "project-urls": |
615 mode = self.ShowProcessUrlsListMode |
622 mode = PipPackageInformationMode.UrlsList |
616 infoWidget.scrollToTop() |
623 infoWidget.scrollToTop() |
617 |
624 |
618 header = infoWidget.header() |
625 header = infoWidget.header() |
619 header.setStretchLastSection(False) |
626 header.setStretchLastSection(False) |
620 header.resizeSections(QHeaderView.ResizeMode.ResizeToContents) |
627 header.resizeSections(QHeaderView.ResizeMode.ResizeToContents) |