diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/CycloneDXInterface/CycloneDXMetaDataDialog.py --- a/src/eric7/CycloneDXInterface/CycloneDXMetaDataDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/CycloneDXInterface/CycloneDXMetaDataDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -20,29 +20,38 @@ """ Class implementing a dialog to edit the metadata of the CycloneDX SBOM. """ + ComponentTypeMapping = { ComponentType.APPLICATION: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Application"), + "CycloneDXMetaDataDialog", "Application" + ), ComponentType.CONTAINER: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Container"), + "CycloneDXMetaDataDialog", "Container" + ), ComponentType.DEVICE: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Device"), + "CycloneDXMetaDataDialog", "Device" + ), ComponentType.FILE: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "File"), + "CycloneDXMetaDataDialog", "File" + ), ComponentType.FIRMWARE: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Firmware"), + "CycloneDXMetaDataDialog", "Firmware" + ), ComponentType.FRAMEWORK: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Framework"), + "CycloneDXMetaDataDialog", "Framework" + ), ComponentType.LIBRARY: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Library"), + "CycloneDXMetaDataDialog", "Library" + ), ComponentType.OPERATING_SYSTEM: QCoreApplication.translate( - "CycloneDXMetaDataDialog", "Operating System"), + "CycloneDXMetaDataDialog", "Operating System" + ), } - + def __init__(self, metadata=None, parent=None): """ Constructor - + @param metadata dictionary containing metadata to populate the dialog (defaults to None) @type dict (optional) @@ -51,10 +60,10 @@ """ super().__init__(parent) self.setupUi(self) - + self.__populateComponentTypeSelector() self.__populateLicenseSelector() - + if metadata: # populate the dialog from given metadata dictionary self.nameEdit.setText(metadata["Name"]) @@ -67,51 +76,52 @@ self.supplierEdit.setText(metadata["Supplier"]) index = self.typeComboBox.findData(metadata["Type"]) self.typeComboBox.setCurrentIndex(index) - + self.nameEdit.textChanged.connect(self.__updateOkButton) self.typeComboBox.currentTextChanged.connect(self.__updateOkButton) self.licenseComboBox.currentTextChanged.connect(self.__updateOkButton) - + self.__updateOkButton() - + def __populateComponentTypeSelector(self): """ Private method to populate the component type selector. """ self.typeComboBox.addItem("", "") for componentType, displayStr in sorted( - CycloneDXMetaDataDialog.ComponentTypeMapping.items(), - key=lambda x: x[1] + CycloneDXMetaDataDialog.ComponentTypeMapping.items(), key=lambda x: x[1] ): self.typeComboBox.addItem(displayStr, componentType) - + def __populateLicenseSelector(self): """ Private method to populate the license selector with the list of trove license types. """ self.licenseComboBox.addItem("") - self.licenseComboBox.addItems(sorted( - classifier.split("::")[-1].strip() - for classifier in trove_classifiers.classifiers - if classifier.startswith("License ::") - )) - + self.licenseComboBox.addItems( + sorted( + classifier.split("::")[-1].strip() + for classifier in trove_classifiers.classifiers + if classifier.startswith("License ::") + ) + ) + @pyqtSlot() def __updateOkButton(self): """ Private slot to update the enabled state of the OK button. """ self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( - bool(self.nameEdit.text()) and - bool(self.typeComboBox.currentText()) and - bool(self.licenseComboBox.currentText()) + bool(self.nameEdit.text()) + and bool(self.typeComboBox.currentText()) + and bool(self.licenseComboBox.currentText()) ) - + def getMetaData(self): """ Public method to get the entered data. - + @return dictionary containing the metadata. @rtype dict """