eric7/PipInterface/PipLicensesDialog.py

branch
eric7
changeset 9108
19a57544f32c
parent 9103
8ac26b4c4316
child 9192
a763d57e23bc
equal deleted inserted replaced
9107:8e9525a780ae 9108:19a57544f32c
6 """ 6 """
7 Module implementing a dialog to show the licenses of an environment. 7 Module implementing a dialog to show the licenses of an environment.
8 """ 8 """
9 9
10 import os 10 import os
11 import re
11 12
12 from PyQt6.QtCore import pyqtSlot, Qt 13 from PyQt6.QtCore import pyqtSlot, Qt
13 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem 14 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem
14 15
15 from EricGui.EricOverrideCursor import EricOverrideCursor 16 from EricGui.EricOverrideCursor import EricOverrideCursor
140 141
141 enable = bool(self.licensesList.topLevelItemCount()) 142 enable = bool(self.licensesList.topLevelItemCount())
142 self.__saveCSVButton.setEnabled(enable) 143 self.__saveCSVButton.setEnabled(enable)
143 144
144 @pyqtSlot(str) 145 @pyqtSlot(str)
145 def __filterPackagesByLicense(self, license): 146 def __filterPackagesByLicense(self, licenseName):
146 """ 147 """
147 Private slot to filter the list of packages by license. 148 Private slot to filter the list of packages by license.
148 149
149 @param license license name 150 @param licenseName license name
150 @type str 151 @type str
151 """ 152 """
153 pattern = r"\b{0}".format(re.escape(licenseName))
154 if not licenseName.endswith((")", "]", "}")):
155 pattern += r"\b"
156 regexp = re.compile(pattern)
152 for row in range(self.licensesList.topLevelItemCount()): 157 for row in range(self.licensesList.topLevelItemCount()):
153 itm = self.licensesList.topLevelItem(row) 158 itm = self.licensesList.topLevelItem(row)
154 if license == self.__allFilter: 159 if licenseName == self.__allFilter:
155 itm.setHidden(False) 160 itm.setHidden(False)
156 else: 161 else:
157 itm.setHidden(license not in itm.text( 162 itm.setHidden(
158 PipLicensesDialog.LicensesLicenseColumn 163 regexp.search(
159 )) 164 itm.text(PipLicensesDialog.LicensesLicenseColumn)
165 ) is None
166 )
160 167
161 @pyqtSlot() 168 @pyqtSlot()
162 def __saveAsCSV(self): 169 def __saveAsCSV(self):
163 """ 170 """
164 Private slot to save the license information as a CSV file. 171 Private slot to save the license information as a CSV file.

eric ide

mercurial