src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
--- a/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/VcsPlugins/vcsMercurial/HgUserConfigHostFingerprintDialog.py	Wed Jul 13 14:55:47 2022 +0200
@@ -10,28 +10,25 @@
 from PyQt6.QtCore import pyqtSlot
 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
 
-from .Ui_HgUserConfigHostFingerprintDialog import (
-    Ui_HgUserConfigHostFingerprintDialog
-)
+from .Ui_HgUserConfigHostFingerprintDialog import Ui_HgUserConfigHostFingerprintDialog
 
 
-class HgUserConfigHostFingerprintDialog(
-        QDialog, Ui_HgUserConfigHostFingerprintDialog):
+class HgUserConfigHostFingerprintDialog(QDialog, Ui_HgUserConfigHostFingerprintDialog):
     """
     Class implementing a dialog to edit a host fingerprint.
     """
+
     supportedHashes = ("sha1", "sha256", "sha512")
     fingerprintLength = {
         "sha1": 40,
         "sha256": 64,
         "sha512": 128,
     }
-    
-    def __init__(self, parent=None, host="", fingerprint="",
-                 version=(0, 0, 0)):
+
+    def __init__(self, parent=None, host="", fingerprint="", version=(0, 0, 0)):
         """
         Constructor
-        
+
         @param parent reference to the parent widget
         @type QWidget
         @param host host name
@@ -43,12 +40,11 @@
         """
         super().__init__(parent)
         self.setupUi(self)
-        
+
         self.__version = version
-        
+
         self.hashComboBox.addItem("")
-        self.hashComboBox.addItems(
-            HgUserConfigHostFingerprintDialog.supportedHashes)
+        self.hashComboBox.addItems(HgUserConfigHostFingerprintDialog.supportedHashes)
         if self.__version < (3, 9, 0):
             self.hashLabel.setEnabled(False)
             self.hashComboBox.setEnabled(False)
@@ -58,62 +54,58 @@
                 hashType, fingerprint = fingerprint.split(":", 1)
             else:
                 hashType = ""
-        
+
         index = self.hashComboBox.findText(hashType)
         self.hashComboBox.setCurrentIndex(index)
         self.hostEdit.setText(host)
         self.fingerprintEdit.setText(fingerprint)
-        
+
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
-        
+
         self.__updateOkButton()
-    
+
     def __updateOkButton(self):
         """
         Private method to update the status of the Ok button.
         """
-        enabled = (
-            bool(self.hostEdit.text()) and
-            bool(self.fingerprintEdit.text())
-        )
+        enabled = bool(self.hostEdit.text()) and bool(self.fingerprintEdit.text())
         if self.__version >= (3, 9, 0):
             hashType = self.hashComboBox.currentText()
             enabled &= bool(hashType)
             if hashType:
                 enabled &= (
-                    len(self.fingerprintEdit.text().replace(":", "")) ==
-                    HgUserConfigHostFingerprintDialog.fingerprintLength[
-                        hashType])
-        
-        self.buttonBox.button(
-            QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
-    
+                    len(self.fingerprintEdit.text().replace(":", ""))
+                    == HgUserConfigHostFingerprintDialog.fingerprintLength[hashType]
+                )
+
+        self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enabled)
+
     @pyqtSlot(str)
     def on_hostEdit_textChanged(self, txt):
         """
         Private slot to handle changes of the host edit.
-        
+
         @param txt current text
         @type str
         """
         self.__updateOkButton()
-    
+
     @pyqtSlot(int)
     def on_hashComboBox_currentIndexChanged(self, index):
         """
         Private slot to handle changes of the hash combo.
-        
+
         @param index current index
         @type int
         """
         self.__updateOkButton()
-    
+
     @pyqtSlot(str)
     def on_fingerprintEdit_textChanged(self, txt):
         """
         Private slot to handle changes of the fingerprint edit.
-        
+
         @param txt current text
         @type str
         """
@@ -121,31 +113,32 @@
             # get rid of whitespace
             txt = txt.strip()
             self.fingerprintEdit.setText(txt)
-        
-        if txt.startswith(tuple(
-            h + ":" for h in
-                HgUserConfigHostFingerprintDialog.supportedHashes)):
+
+        if txt.startswith(
+            tuple(h + ":" for h in HgUserConfigHostFingerprintDialog.supportedHashes)
+        ):
             parts = txt.split(":", 1)
             if len(parts) == 2:
                 self.fingerprintEdit.setText(parts[1])
                 hashIndex = self.hashComboBox.findText(parts[0].strip())
                 if hashIndex > -1:
                     self.hashComboBox.setCurrentIndex(hashIndex)
-        
+
         self.__updateOkButton()
-    
+
     def getData(self):
         """
         Public method to retrieve the data.
-        
+
         @return tuple containig the host name and the fingerprint
         @rtype tuple of two str
         """
         fingerprint = (
             self.fingerprintEdit.text()
-            if self.__version < (3, 9, 0) else
-            "{0}:{1}".format(self.hashComboBox.currentText(),
-                             self.fingerprintEdit.text().strip())
+            if self.__version < (3, 9, 0)
+            else "{0}:{1}".format(
+                self.hashComboBox.currentText(), self.fingerprintEdit.text().strip()
+            )
         )
-        
+
         return self.hostEdit.text().strip(), fingerprint

eric ide

mercurial