5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to edit the metadata of the CycloneDX SBOM. |
7 Module implementing a dialog to edit the metadata of the CycloneDX SBOM. |
8 """ |
8 """ |
9 |
9 |
10 import os |
|
11 |
|
12 from PyQt6.QtCore import pyqtSlot, QCoreApplication |
10 from PyQt6.QtCore import pyqtSlot, QCoreApplication |
13 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
14 |
12 |
15 from EricWidgets import EricMessageBox |
|
16 |
|
17 from cyclonedx.model.component import ComponentType |
13 from cyclonedx.model.component import ComponentType |
|
14 import trove_classifiers |
18 |
15 |
19 from .Ui_CycloneDXMetaDataDialog import Ui_CycloneDXMetaDataDialog |
16 from .Ui_CycloneDXMetaDataDialog import Ui_CycloneDXMetaDataDialog |
20 |
17 |
21 |
18 |
22 class CycloneDXMetaDataDialog(QDialog, Ui_CycloneDXMetaDataDialog): |
19 class CycloneDXMetaDataDialog(QDialog, Ui_CycloneDXMetaDataDialog): |
90 |
87 |
91 def __populateLicenseSelector(self): |
88 def __populateLicenseSelector(self): |
92 """ |
89 """ |
93 Private method to populate the license selector with the list of trove |
90 Private method to populate the license selector with the list of trove |
94 license types. |
91 license types. |
95 |
|
96 Note: The trove licanese list file was created from querying |
|
97 "https://pypi.org/pypi?%3Aaction=list_classifiers". |
|
98 """ |
92 """ |
99 filename = os.path.join( |
|
100 os.path.dirname(__file__), "..", "data", |
|
101 "trove_license_classifiers.txt") |
|
102 try: |
|
103 with open(filename, "r") as f: |
|
104 lines = f.readlines() |
|
105 except OSError as err: |
|
106 EricMessageBox.warning( |
|
107 self, |
|
108 self.tr("Reading Trove License Classifiers"), |
|
109 self.tr("""<p>The Trove License Classifiers file <b>{0}</b>""" |
|
110 """ could not be read.</p><p>Reason: {1}</p>""") |
|
111 .format(filename, str(err))) |
|
112 return |
|
113 |
|
114 self.licenseComboBox.addItem("") |
93 self.licenseComboBox.addItem("") |
115 self.licenseComboBox.addItems(sorted( |
94 self.licenseComboBox.addItems(sorted( |
116 line.split("::")[-1].strip() |
95 classifier.split("::")[-1].strip() |
117 for line in lines |
96 for classifier in trove_classifiers.classifiers |
118 if line.startswith("License ") # play it safe |
97 if classifier.startswith("License ::") |
119 )) |
98 )) |
120 |
99 |
121 @pyqtSlot() |
100 @pyqtSlot() |
122 def __updateOkButton(self): |
101 def __updateOkButton(self): |
123 """ |
102 """ |