Sat, 02 Apr 2022 17:07:56 +0200
pip Interface
- added the capability to save the licenses overview as a CSV file
--- a/docs/changelog Sat Apr 02 16:01:33 2022 +0200 +++ b/docs/changelog Sat Apr 02 17:07:56 2022 +0200 @@ -2,6 +2,8 @@ ---------- Version 22.5: - bug fixes +- pip Interface + -- added the capability to save the licenses overview as a CSV file Version 22.4: - bug fixes
--- a/eric7/Documentation/Help/source.qhp Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/Documentation/Help/source.qhp Sat Apr 02 17:07:56 2022 +0200 @@ -11411,6 +11411,7 @@ <keyword name="PipLicensesDialog (Constructor)" id="PipLicensesDialog (Constructor)" ref="eric7.PipInterface.PipLicensesDialog.html#PipLicensesDialog.__init__" /> <keyword name="PipLicensesDialog (Module)" id="PipLicensesDialog (Module)" ref="eric7.PipInterface.PipLicensesDialog.html" /> <keyword name="PipLicensesDialog.__refreshLicenses" id="PipLicensesDialog.__refreshLicenses" ref="eric7.PipInterface.PipLicensesDialog.html#PipLicensesDialog.__refreshLicenses" /> + <keyword name="PipLicensesDialog.__saveAsCSV" id="PipLicensesDialog.__saveAsCSV" ref="eric7.PipInterface.PipLicensesDialog.html#PipLicensesDialog.__saveAsCSV" /> <keyword name="PipPackageDetailsDialog" id="PipPackageDetailsDialog" ref="eric7.PipInterface.PipPackageDetailsDialog.html#PipPackageDetailsDialog" /> <keyword name="PipPackageDetailsDialog (Constructor)" id="PipPackageDetailsDialog (Constructor)" ref="eric7.PipInterface.PipPackageDetailsDialog.html#PipPackageDetailsDialog.__init__" /> <keyword name="PipPackageDetailsDialog (Module)" id="PipPackageDetailsDialog (Module)" ref="eric7.PipInterface.PipPackageDetailsDialog.html" />
--- a/eric7/Documentation/Source/eric7.PipInterface.PipLicensesDialog.html Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/Documentation/Source/eric7.PipInterface.PipLicensesDialog.html Sat Apr 02 17:07:56 2022 +0200 @@ -62,6 +62,10 @@ <td><a href="#PipLicensesDialog.__refreshLicenses">__refreshLicenses</a></td> <td>Private slot to refresh the license lists.</td> </tr> +<tr> +<td><a href="#PipLicensesDialog.__saveAsCSV">__saveAsCSV</a></td> +<td>Private slot to save the license information as a CSV file.</td> +</tr> </table> <h3>Static Methods</h3> @@ -108,6 +112,13 @@ <p> Private slot to refresh the license lists. </p> +<a NAME="PipLicensesDialog.__saveAsCSV" ID="PipLicensesDialog.__saveAsCSV"></a> +<h4>PipLicensesDialog.__saveAsCSV</h4> +<b>__saveAsCSV</b>(<i></i>) + +<p> + Private slot to save the license information as a CSV file. +</p> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html> \ No newline at end of file
--- a/eric7/PipInterface/PipLicensesDialog.py Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/PipInterface/PipLicensesDialog.py Sat Apr 02 17:07:56 2022 +0200 @@ -7,10 +7,13 @@ Module implementing a dialog to show the licenses of an environment. """ +import os + from PyQt6.QtCore import pyqtSlot, Qt -from PyQt6.QtWidgets import QDialog, QTreeWidgetItem +from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QTreeWidgetItem from EricGui.EricOverrideCursor import EricOverrideCursor +from EricWidgets import EricFileDialog, EricMessageBox from .Ui_PipLicensesDialog import Ui_PipLicensesDialog @@ -50,6 +53,13 @@ self.__pip = pip self.__environment = environment + self.__saveCSVButton = self.buttonBox.addButton( + self.tr("Save as CSV..."), QDialogButtonBox.ButtonRole.ActionRole) + self.__saveCSVButton.clicked.connect(self.__saveAsCSV) + + self.buttonBox.button( + QDialogButtonBox.StandardButton.Close).setDefault(True) + self.localCheckBox.setChecked(localPackages) self.userCheckBox.setChecked(usersite) @@ -115,3 +125,53 @@ for col in range(self.summaryList.columnCount()): self.summaryList.resizeColumnToContents(col) self.summaryList.setUpdatesEnabled(True) + + enable = bool(self.licensesList.topLevelItemCount()) + self.__saveCSVButton.setEnabled(enable) + + @pyqtSlot() + def __saveAsCSV(self): + """ + Private slot to save the license information as a CSV file. + """ + import csv + + fileName, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( + self, + self.tr("Save as CSV"), + os.path.expanduser("~"), + self.tr("CSV Files (*.csv);;All Files (*)"), + None, + EricFileDialog.DontConfirmOverwrite + ) + if fileName: + ext = os.path.splitext(fileName)[1] + if not ext: + ex = selectedFilter.split("(*")[1].split(")")[0] + if ex: + fileName += ex + + try: + with open(fileName, "w", newline="", + encoding="utf-8") as csvFile: + fieldNames = ["Name", "Version", "License"] + writer = csv.DictWriter(csvFile, fieldnames=fieldNames) + + writer.writeheader() + for row in range(self.licensesList.topLevelItemCount()): + itm = self.licensesList.topLevelItem(row) + writer.writerow({ + "Name": itm.text(0), + "Version": itm.text(1), + "License": itm.text(2), + }) + except OSError as err: + EricMessageBox.critical( + self, + self.tr("Save as CSV"), + self.tr( + """<p>The license information could not be saved""" + """ into the CSV file <b>{0}</b>.</p>""" + """<p>Reason: {1}</p>""" + ).format(fileName, str(err)) + )
--- a/eric7/i18n/eric7_cs.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_cs.ts Sat Apr 02 17:07:56 2022 +0200 @@ -55212,15 +55212,36 @@ <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipListDialog</name>
--- a/eric7/i18n/eric7_de.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_de.ts Sat Apr 02 17:07:56 2022 +0200 @@ -51673,15 +51673,36 @@ <translation>Anzahl</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation>Als CSV speichern...</translation> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation>Lizenzen für "{0}"</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation>Keine Umgebung angegeben.</translation> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation>Als CSV speichern</translation> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation>CSV Dateien (*.csv);;Alle Dateien (*)</translation> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation><p>Die Lizenzinformationen konnten nicht in der Datei <b>{0}</b> gespeichert werden.</p><p>Ursache: {1}</p></translation> + </message> </context> <context> <name>PipPackageDetailsDialog</name>
--- a/eric7/i18n/eric7_empty.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_empty.ts Sat Apr 02 17:07:56 2022 +0200 @@ -51415,15 +51415,36 @@ <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipPackageDetailsDialog</name>
--- a/eric7/i18n/eric7_en.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_en.ts Sat Apr 02 17:07:56 2022 +0200 @@ -51460,15 +51460,36 @@ <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipPackageDetailsDialog</name>
--- a/eric7/i18n/eric7_es.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_es.ts Sat Apr 02 17:07:56 2022 +0200 @@ -51675,15 +51675,36 @@ <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipPackageDetailsDialog</name>
--- a/eric7/i18n/eric7_fr.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_fr.ts Sat Apr 02 17:07:56 2022 +0200 @@ -55491,15 +55491,36 @@ <translation type="unfinished">Nombre</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipListDialog</name>
--- a/eric7/i18n/eric7_it.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_it.ts Sat Apr 02 17:07:56 2022 +0200 @@ -57317,15 +57317,36 @@ <translation type="unfinished">Contatore</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipListDialog</name>
--- a/eric7/i18n/eric7_pt.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_pt.ts Sat Apr 02 17:07:56 2022 +0200 @@ -56806,15 +56806,36 @@ <translation type="unfinished">Contagem</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipListDialog</name>
--- a/eric7/i18n/eric7_ru.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_ru.ts Sat Apr 02 17:07:56 2022 +0200 @@ -51755,15 +51755,36 @@ <translation>Количество</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation>Лицензии "{0}"</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation>Не задана среда окружения.</translation> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipPackageDetailsDialog</name>
--- a/eric7/i18n/eric7_tr.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_tr.ts Sat Apr 02 17:07:56 2022 +0200 @@ -55522,15 +55522,36 @@ <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipListDialog</name>
--- a/eric7/i18n/eric7_zh_CN.ts Sat Apr 02 16:01:33 2022 +0200 +++ b/eric7/i18n/eric7_zh_CN.ts Sat Apr 02 17:07:56 2022 +0200 @@ -56387,15 +56387,36 @@ <translation type="unfinished">总计</translation> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="61" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="57" /> + <source>Save as CSV...</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="71" /> <source>Licenses of "{0}"</source> <translation type="unfinished" /> </message> <message> - <location filename="../PipInterface/PipLicensesDialog.py" line="65" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="75" /> <source>No environment specified.</source> <translation type="unfinished" /> </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="171" /> + <location filename="../PipInterface/PipLicensesDialog.py" line="141" /> + <source>Save as CSV</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="143" /> + <source>CSV Files (*.csv);;All Files (*)</source> + <translation type="unfinished" /> + </message> + <message> + <location filename="../PipInterface/PipLicensesDialog.py" line="172" /> + <source><p>The license information could not be saved into the CSV file <b>{0}</b>.</p><p>Reason: {1}</p></source> + <translation type="unfinished" /> + </message> </context> <context> <name>PipListDialog</name>