PluginWizardDataUriEncoder.py

branch
eric7
changeset 50
4d34c264a71d
parent 48
d9cd58b1e0c8
child 51
619765dd3aa8
--- a/PluginWizardDataUriEncoder.py	Thu Dec 30 13:58:24 2021 +0100
+++ b/PluginWizardDataUriEncoder.py	Tue Sep 20 17:00:19 2022 +0200
@@ -40,33 +40,34 @@
     """
     Class implementing the base64 data URI encoder wizard plug-in.
     """
+
     def __init__(self, ui):
         """
         Constructor
-        
+
         @param ui reference to the user interface object
         @type UserInterface
         """
         QObject.__init__(self, ui)
-        
+
         self.__ui = ui
         self.__action = None
-        
+
         self.__translator = None
         self.__loadTranslator()
-    
+
     def activate(self):
         """
         Public method to activate this plug-in.
-        
+
         @return tuple of None and activation status
         @rtype (None, bool)
         """
         self.__initAction()
         self.__initMenu()
-        
+
         return None, True
-    
+
     def deactivate(self):
         """
         Public method to deactivate this plug-in.
@@ -74,8 +75,8 @@
         menu = self.__ui.getMenu("wizards")
         if menu:
             menu.removeAction(self.__action)
-        self.__ui.removeEricActions([self.__action], 'wizards')
-    
+        self.__ui.removeEricActions([self.__action], "wizards")
+
     def __loadTranslator(self):
         """
         Private method to load the translation file.
@@ -84,7 +85,8 @@
             loc = self.__ui.getLocale()
             if loc and loc != "C":
                 locale_dir = os.path.join(
-                    os.path.dirname(__file__), "WizardDataUriEncoder", "i18n")
+                    os.path.dirname(__file__), "WizardDataUriEncoder", "i18n"
+                )
                 translation = "datauriencoder_{0}".format(loc)
                 translator = QTranslator(None)
                 loaded = translator.load(translation, locale_dir)
@@ -92,29 +94,35 @@
                     self.__translator = translator
                     ericApp().installTranslator(self.__translator)
                 else:
-                    print("Warning: translation file '{0}' could not be"
-                          " loaded.".format(translation))
+                    print(
+                        "Warning: translation file '{0}' could not be"
+                        " loaded.".format(translation)
+                    )
                     print("Using default.")
-    
+
     def __initAction(self):
         """
         Private method to initialize the action.
         """
         self.__action = EricAction(
-            self.tr('Base64 Data Uri Encoder Wizard'),
-            self.tr('Base&64 Data Uri Encoder Wizard...'),
-            0, 0, self,
-            'wizards_datauriencoder')
-        self.__action.setStatusTip(self.tr(
-            'Base64 Data Uri Encoder Wizard'))
-        self.__action.setWhatsThis(self.tr(
-            """<b>Base64 Data Uri Encoder Wizard</b>"""
-            """<p>This wizard opens a dialog for entering all the parameters"""
-            """ needed to create code for a base64 encoded data URI.</p>"""
-        ))
+            self.tr("Base64 Data Uri Encoder Wizard"),
+            self.tr("Base&64 Data Uri Encoder Wizard..."),
+            0,
+            0,
+            self,
+            "wizards_datauriencoder",
+        )
+        self.__action.setStatusTip(self.tr("Base64 Data Uri Encoder Wizard"))
+        self.__action.setWhatsThis(
+            self.tr(
+                """<b>Base64 Data Uri Encoder Wizard</b>"""
+                """<p>This wizard opens a dialog for entering all the parameters"""
+                """ needed to create code for a base64 encoded data URI.</p>"""
+            )
+        )
         self.__action.triggered.connect(self.__handle)
-        
-        self.__ui.addEricActions([self.__action], 'wizards')
+
+        self.__ui.addEricActions([self.__action], "wizards")
 
     def __initMenu(self):
         """
@@ -123,22 +131,24 @@
         menu = self.__ui.getMenu("wizards")
         if menu:
             menu.addAction(self.__action)
-    
+
     def __handle(self):
         """
         Private method to handle the wizards action.
         """
         editor = ericApp().getObject("ViewManager").activeWindow()
-        
+
         if editor is None:
             EricMessageBox.critical(
                 self.__ui,
-                self.tr('No current editor'),
-                self.tr('Please open or create a file first.'))
+                self.tr("No current editor"),
+                self.tr("Please open or create a file first."),
+            )
         else:
             from WizardDataUriEncoder.DataUriEncoderWizardDialog import (
-                DataUriEncoderWizardDialog
+                DataUriEncoderWizardDialog,
             )
+
             dlg = DataUriEncoderWizardDialog(None)
             if dlg.exec() == QDialog.DialogCode.Accepted:
                 code = dlg.getCode()
@@ -149,5 +159,6 @@
                     editor.insertAt(code, line, index)
                     editor.endUndoAction()
 
+
 #
 # eflag: noqa = M801

eric ide

mercurial