src/eric7/Plugins/PluginEricapi.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9212
1c5cf2022c7e
child 9413
80c06d472826
--- a/src/eric7/Plugins/PluginEricapi.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Plugins/PluginEricapi.py	Wed Jul 13 14:55:47 2022 +0200
@@ -45,11 +45,11 @@
 def exeDisplayData():
     """
     Public method to support the display of some executable info.
-    
+
     @return dictionary containing the data to query the presence of
         the executable
     """
-    exe = 'eric7_api'
+    exe = "eric7_api"
     if Utilities.isWindowsPlatform():
         for exepath in (
             getConfig("bindir"),
@@ -73,19 +73,20 @@
             if os.path.exists(exe_):
                 exe = exe_
                 break
-    
+
     data = {
         "programEntry": True,
         "header": QCoreApplication.translate(
-            "EricapiPlugin", "eric API File Generator"),
+            "EricapiPlugin", "eric API File Generator"
+        ),
         "exe": exe,
-        "versionCommand": '--version',
-        "versionStartsWith": 'eric7_',
+        "versionCommand": "--version",
+        "versionStartsWith": "eric7_",
         "versionPosition": -3,
         "version": "",
         "versionCleanup": None,
     }
-    
+
     return data
 
 
@@ -93,16 +94,17 @@
     """
     Class implementing the Ericapi plugin.
     """
+
     def __init__(self, ui):
         """
         Constructor
-        
+
         @param ui reference to the user interface object (UI.UserInterface)
         """
         super().__init__(ui)
         self.__ui = ui
         self.__initialize()
-        
+
     def __initialize(self):
         """
         Private slot to (re)initialize the plugin.
@@ -112,108 +114,110 @@
     def activate(self):
         """
         Public method to activate this plugin.
-        
+
         @return tuple of None and activation status (boolean)
         """
         menu = ericApp().getObject("Project").getMenu("Apidoc")
         if menu:
             self.__projectAct = EricAction(
-                self.tr('Generate API file (eric7_api)'),
-                self.tr('Generate &API file (eric7_api)'), 0, 0,
-                self, 'doc_eric7_api')
-            self.__projectAct.setStatusTip(self.tr(
-                'Generate an API file using eric7_api'))
-            self.__projectAct.setWhatsThis(self.tr(
-                """<b>Generate API file</b>"""
-                """<p>Generate an API file using eric7_api.</p>"""
-            ))
+                self.tr("Generate API file (eric7_api)"),
+                self.tr("Generate &API file (eric7_api)"),
+                0,
+                0,
+                self,
+                "doc_eric7_api",
+            )
+            self.__projectAct.setStatusTip(
+                self.tr("Generate an API file using eric7_api")
+            )
+            self.__projectAct.setWhatsThis(
+                self.tr(
+                    """<b>Generate API file</b>"""
+                    """<p>Generate an API file using eric7_api.</p>"""
+                )
+            )
             self.__projectAct.triggered.connect(self.__doEricapi)
             ericApp().getObject("Project").addEricActions([self.__projectAct])
             menu.addAction(self.__projectAct)
-        
+
         ericApp().getObject("Project").showMenu.connect(self.__projectShowMenu)
-        
+
         return None, True
 
     def deactivate(self):
         """
         Public method to deactivate this plugin.
         """
-        ericApp().getObject("Project").showMenu.disconnect(
-            self.__projectShowMenu)
-        
+        ericApp().getObject("Project").showMenu.disconnect(self.__projectShowMenu)
+
         menu = ericApp().getObject("Project").getMenu("Apidoc")
         if menu:
             menu.removeAction(self.__projectAct)
-            ericApp().getObject("Project").removeEricActions(
-                [self.__projectAct])
+            ericApp().getObject("Project").removeEricActions([self.__projectAct])
         self.__initialize()
-    
+
     def __projectShowMenu(self, menuName, menu):
         """
         Private slot called, when the the project menu or a submenu is
         about to be shown.
-        
+
         @param menuName name of the menu to be shown (string)
         @param menu reference to the menu (QMenu)
         """
         if menuName == "Apidoc" and self.__projectAct is not None:
             self.__projectAct.setEnabled(
-                ericApp().getObject("Project").getProjectLanguage() in
-                ["Python", "Python3", "Ruby", "MicroPython"])
-    
+                ericApp().getObject("Project").getProjectLanguage()
+                in ["Python", "Python3", "Ruby", "MicroPython"]
+            )
+
     def __doEricapi(self):
         """
         Private slot to perform the eric7_api api generation.
         """
-        from DocumentationPlugins.Ericapi.EricapiConfigDialog import (
-            EricapiConfigDialog
-        )
+        from DocumentationPlugins.Ericapi.EricapiConfigDialog import EricapiConfigDialog
+
         eolTranslation = {
-            '\r': 'cr',
-            '\n': 'lf',
-            '\r\n': 'crlf',
+            "\r": "cr",
+            "\n": "lf",
+            "\r\n": "crlf",
         }
         project = ericApp().getObject("Project")
-        parms = project.getData('DOCUMENTATIONPARMS', "ERIC4API")
+        parms = project.getData("DOCUMENTATIONPARMS", "ERIC4API")
         dlg = EricapiConfigDialog(project, parms)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             args, parms, startDir = dlg.generateParameters()
-            project.setData('DOCUMENTATIONPARMS', "ERIC4API", parms)
-            
+            project.setData("DOCUMENTATIONPARMS", "ERIC4API", parms)
+
             if not startDir:
                 startDir = project.ppath
-            
+
             # add parameter for the eol setting
             if not project.useSystemEol():
-                args.append(
-                    "--eol={0}".format(eolTranslation[project.getEolString()]))
-            
+                args.append("--eol={0}".format(eolTranslation[project.getEolString()]))
+
             # now do the call
-            from DocumentationPlugins.Ericapi.EricapiExecDialog import (
-                EricapiExecDialog
-            )
+            from DocumentationPlugins.Ericapi.EricapiExecDialog import EricapiExecDialog
+
             dia = EricapiExecDialog("Ericapi")
             res = dia.start(args, startDir)
             if res:
                 dia.exec()
-            
-            outputFileName = Utilities.toNativeSeparators(parms['outputFile'])
-            
+
+            outputFileName = Utilities.toNativeSeparators(parms["outputFile"])
+
             # add output files to the project data, if they aren't in already
-            for progLanguage in parms['languages']:
+            for progLanguage in parms["languages"]:
                 if "%L" in outputFileName:
                     outfile = outputFileName.replace("%L", progLanguage)
                 else:
-                    if len(parms['languages']) == 1:
+                    if len(parms["languages"]) == 1:
                         outfile = outputFileName
                     else:
                         root, ext = os.path.splitext(outputFileName)
-                        outfile = "{0}-{1}{2}".format(
-                            root, progLanguage.lower(), ext)
-                
+                        outfile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext)
+
                 outfile = project.getRelativePath(outfile)
-                if outfile not in project.pdata['OTHERS']:
-                    project.pdata['OTHERS'].append(outfile)
+                if outfile not in project.pdata["OTHERS"]:
+                    project.pdata["OTHERS"].append(outfile)
                     project.setDirty(True)
                     project.othersAdded(outfile)

eric ide

mercurial