Mon, 27 Sep 2021 15:43:50 +0200
Changed the 'multiprocessing.Process()' code of the background batch services to (hopefully) cure the slow down when used multiple times.
<!DOCTYPE html> <html><head> <title>Plugin_Metrics_Radon.PluginMetricsRadon</title> <meta charset="UTF-8"> <link rel="stylesheet" href="styles.css"> </head> <body> <a NAME="top" ID="top"></a> <h1>Plugin_Metrics_Radon.PluginMetricsRadon</h1> <p> Module implementing the radon code metrics plug-in. </p> <h3>Global Attributes</h3> <table> <tr><td>author</td></tr><tr><td>autoactivate</td></tr><tr><td>className</td></tr><tr><td>deactivateable</td></tr><tr><td>error</td></tr><tr><td>longDescription</td></tr><tr><td>name</td></tr><tr><td>needsRestart</td></tr><tr><td>packageName</td></tr><tr><td>pyqtApi</td></tr><tr><td>shortDescription</td></tr><tr><td>version</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#RadonMetricsPlugin">RadonMetricsPlugin</a></td> <td>Class implementing the radon code metrics plug-in.</td> </tr> </table> <h3>Functions</h3> <table> <tr> <td><a href="#installDependencies">installDependencies</a></td> <td>Function to install dependencies of this plug-in.</td> </tr> </table> <hr /> <hr /> <a NAME="RadonMetricsPlugin" ID="RadonMetricsPlugin"></a> <h2>RadonMetricsPlugin</h2> <p> Class implementing the radon code metrics plug-in. </p> <h3>Signals</h3> <dl> <dt>batchFinished(str)</dt> <dd> emitted when a code metrics batch is done </dd> <dt>complexityDone(str, dict)</dt> <dd> emitted when the cyclomatic complexity was determined for a file </dd> <dt>error(str, str, str)</dt> <dd> emitted in case of an error </dd> <dt>maintainabilityIndexDone(str, dict)</dt> <dd> emitted when the maintainability index was determined for a file </dd> <dt>metricsDone(str, dict)</dt> <dd> emitted when the code metrics were determined for a file </dd> </dl> <h3>Derived from</h3> QObject <h3>Class Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Class Methods</h3> <table> <tr><td>None</td></tr> </table> <h3>Methods</h3> <table> <tr> <td><a href="#RadonMetricsPlugin.__init__">RadonMetricsPlugin</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorClosed">__editorClosed</a></td> <td>Private slot called, when an editor was closed.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorCyclomaticComplexity">__editorCyclomaticComplexity</a></td> <td>Private slot to handle the cyclomatic complexity action of the editor show menu.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorMaintainabilityIndex">__editorMaintainabilityIndex</a></td> <td>Private slot to handle the maintainability index action of the editor show menu.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorOpened">__editorOpened</a></td> <td>Private slot called, when a new editor was opened.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorRawMetrics">__editorRawMetrics</a></td> <td>Private slot to handle the raw code metrics action of the editor show menu.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorRenamed">__editorRenamed</a></td> <td>Private slot called, when an editor was renamed.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__editorShowMenu">__editorShowMenu</a></td> <td>Private slot called, when the the editor context menu or a submenu is about to be shown.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__initialize">__initialize</a></td> <td>Private slot to (re)initialize the plugin.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__loadTranslator">__loadTranslator</a></td> <td>Private method to load the translation file.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectBrowserCyclomaticComplexity">__projectBrowserCyclomaticComplexity</a></td> <td>Private method to handle the cyclomatic complexity context menu action of the project sources browser.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectBrowserMaintainabilityIndex">__projectBrowserMaintainabilityIndex</a></td> <td>Private method to handle the maintainability index context menu action of the project sources browser.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectBrowserRawMetrics">__projectBrowserRawMetrics</a></td> <td>Private method to handle the code metrics context menu action of the project sources browser.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectBrowserShowMenu">__projectBrowserShowMenu</a></td> <td>Private slot called, when the the project browser context menu or a submenu is about to be shown.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectClosed">__projectClosed</a></td> <td>Private slot to handle closing a project.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectCyclomaticComplexity">__projectCyclomaticComplexity</a></td> <td>Private slot used to calculate the cyclomatic complexity for the project.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectMaintainabilityIndex">__projectMaintainabilityIndex</a></td> <td>Private slot used to calculate the maintainability indexes for the project.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectRawMetrics">__projectRawMetrics</a></td> <td>Private slot used to calculate raw code metrics for the project.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__projectShowMenu">__projectShowMenu</a></td> <td>Private slot called, when the the project menu or a submenu is about to be shown.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__serviceError">__serviceError</a></td> <td>Private slot handling service errors.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.__showRadonVersion">__showRadonVersion</a></td> <td>Private slot to show the version number of the used radon library.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.activate">activate</a></td> <td>Public method to activate this plug-in.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.batchJobDone">batchJobDone</a></td> <td>Public slot handling the completion of a batch job.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.cancelComplexityBatch">cancelComplexityBatch</a></td> <td>Public method to cancel all batch jobs.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.cancelMaintainabilityIndexBatch">cancelMaintainabilityIndexBatch</a></td> <td>Public method to cancel all batch jobs.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.cancelRawMetricsBatch">cancelRawMetricsBatch</a></td> <td>Public method to cancel all batch jobs.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.cyclomaticComplexity">cyclomaticComplexity</a></td> <td>Public method to prepare cyclomatic complexity calculation on one Python source file.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.cyclomaticComplexityBatch">cyclomaticComplexityBatch</a></td> <td>Public method to prepare cyclomatic complexity calculation on multiple Python source files.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.deactivate">deactivate</a></td> <td>Public method to deactivate this plug-in.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.maintainabilityIndex">maintainabilityIndex</a></td> <td>Public method to prepare maintainability index calculation on one Python source file.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.maintainabilityIndexBatch">maintainabilityIndexBatch</a></td> <td>Public method to prepare maintainability index calculation on multiple Python source files.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.metricsCalculationDone">metricsCalculationDone</a></td> <td>Public slot to dispatch the result.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.rawMetrics">rawMetrics</a></td> <td>Public method to prepare raw code metrics calculation on one Python source file.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.rawMetricsBatch">rawMetricsBatch</a></td> <td>Public method to prepare raw code metrics calculation on multiple Python source files.</td> </tr> <tr> <td><a href="#RadonMetricsPlugin.serviceErrorPy3">serviceErrorPy3</a></td> <td>Public slot handling service errors for Python 3.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="RadonMetricsPlugin.__init__" ID="RadonMetricsPlugin.__init__"></a> <h4>RadonMetricsPlugin (Constructor)</h4> <b>RadonMetricsPlugin</b>(<i>ui</i>) <p> Constructor </p> <dl> <dt><i>ui</i> (UserInterface)</dt> <dd> reference to the user interface object </dd> </dl> <a NAME="RadonMetricsPlugin.__editorClosed" ID="RadonMetricsPlugin.__editorClosed"></a> <h4>RadonMetricsPlugin.__editorClosed</h4> <b>__editorClosed</b>(<i>editor</i>) <p> Private slot called, when an editor was closed. </p> <dl> <dt><i>editor</i> (Editor)</dt> <dd> reference to the editor </dd> </dl> <a NAME="RadonMetricsPlugin.__editorCyclomaticComplexity" ID="RadonMetricsPlugin.__editorCyclomaticComplexity"></a> <h4>RadonMetricsPlugin.__editorCyclomaticComplexity</h4> <b>__editorCyclomaticComplexity</b>(<i></i>) <p> Private slot to handle the cyclomatic complexity action of the editor show menu. </p> <a NAME="RadonMetricsPlugin.__editorMaintainabilityIndex" ID="RadonMetricsPlugin.__editorMaintainabilityIndex"></a> <h4>RadonMetricsPlugin.__editorMaintainabilityIndex</h4> <b>__editorMaintainabilityIndex</b>(<i></i>) <p> Private slot to handle the maintainability index action of the editor show menu. </p> <a NAME="RadonMetricsPlugin.__editorOpened" ID="RadonMetricsPlugin.__editorOpened"></a> <h4>RadonMetricsPlugin.__editorOpened</h4> <b>__editorOpened</b>(<i>editor</i>) <p> Private slot called, when a new editor was opened. </p> <dl> <dt><i>editor</i> (Editor)</dt> <dd> reference to the new editor </dd> </dl> <a NAME="RadonMetricsPlugin.__editorRawMetrics" ID="RadonMetricsPlugin.__editorRawMetrics"></a> <h4>RadonMetricsPlugin.__editorRawMetrics</h4> <b>__editorRawMetrics</b>(<i></i>) <p> Private slot to handle the raw code metrics action of the editor show menu. </p> <a NAME="RadonMetricsPlugin.__editorRenamed" ID="RadonMetricsPlugin.__editorRenamed"></a> <h4>RadonMetricsPlugin.__editorRenamed</h4> <b>__editorRenamed</b>(<i>editor</i>) <p> Private slot called, when an editor was renamed. </p> <dl> <dt><i>editor</i> (Editor)</dt> <dd> reference to the renamed editor </dd> </dl> <a NAME="RadonMetricsPlugin.__editorShowMenu" ID="RadonMetricsPlugin.__editorShowMenu"></a> <h4>RadonMetricsPlugin.__editorShowMenu</h4> <b>__editorShowMenu</b>(<i>menuName, menu, editor</i>) <p> Private slot called, when the the editor context menu or a submenu is about to be shown. </p> <dl> <dt><i>menuName</i> (str)</dt> <dd> name of the menu to be shown </dd> <dt><i>menu</i> (QMenu)</dt> <dd> reference to the menu </dd> <dt><i>editor</i> (Editor)</dt> <dd> reference to the editor </dd> </dl> <a NAME="RadonMetricsPlugin.__initialize" ID="RadonMetricsPlugin.__initialize"></a> <h4>RadonMetricsPlugin.__initialize</h4> <b>__initialize</b>(<i></i>) <p> Private slot to (re)initialize the plugin. </p> <a NAME="RadonMetricsPlugin.__loadTranslator" ID="RadonMetricsPlugin.__loadTranslator"></a> <h4>RadonMetricsPlugin.__loadTranslator</h4> <b>__loadTranslator</b>(<i></i>) <p> Private method to load the translation file. </p> <a NAME="RadonMetricsPlugin.__projectBrowserCyclomaticComplexity" ID="RadonMetricsPlugin.__projectBrowserCyclomaticComplexity"></a> <h4>RadonMetricsPlugin.__projectBrowserCyclomaticComplexity</h4> <b>__projectBrowserCyclomaticComplexity</b>(<i></i>) <p> Private method to handle the cyclomatic complexity context menu action of the project sources browser. </p> <a NAME="RadonMetricsPlugin.__projectBrowserMaintainabilityIndex" ID="RadonMetricsPlugin.__projectBrowserMaintainabilityIndex"></a> <h4>RadonMetricsPlugin.__projectBrowserMaintainabilityIndex</h4> <b>__projectBrowserMaintainabilityIndex</b>(<i></i>) <p> Private method to handle the maintainability index context menu action of the project sources browser. </p> <a NAME="RadonMetricsPlugin.__projectBrowserRawMetrics" ID="RadonMetricsPlugin.__projectBrowserRawMetrics"></a> <h4>RadonMetricsPlugin.__projectBrowserRawMetrics</h4> <b>__projectBrowserRawMetrics</b>(<i></i>) <p> Private method to handle the code metrics context menu action of the project sources browser. </p> <a NAME="RadonMetricsPlugin.__projectBrowserShowMenu" ID="RadonMetricsPlugin.__projectBrowserShowMenu"></a> <h4>RadonMetricsPlugin.__projectBrowserShowMenu</h4> <b>__projectBrowserShowMenu</b>(<i>menuName, menu</i>) <p> Private slot called, when the the project browser context menu or a submenu is about to be shown. </p> <dl> <dt><i>menuName</i> (str)</dt> <dd> name of the menu to be shown </dd> <dt><i>menu</i> (QMenu)</dt> <dd> reference to the menu </dd> </dl> <a NAME="RadonMetricsPlugin.__projectClosed" ID="RadonMetricsPlugin.__projectClosed"></a> <h4>RadonMetricsPlugin.__projectClosed</h4> <b>__projectClosed</b>(<i></i>) <p> Private slot to handle closing a project. </p> <a NAME="RadonMetricsPlugin.__projectCyclomaticComplexity" ID="RadonMetricsPlugin.__projectCyclomaticComplexity"></a> <h4>RadonMetricsPlugin.__projectCyclomaticComplexity</h4> <b>__projectCyclomaticComplexity</b>(<i></i>) <p> Private slot used to calculate the cyclomatic complexity for the project. </p> <a NAME="RadonMetricsPlugin.__projectMaintainabilityIndex" ID="RadonMetricsPlugin.__projectMaintainabilityIndex"></a> <h4>RadonMetricsPlugin.__projectMaintainabilityIndex</h4> <b>__projectMaintainabilityIndex</b>(<i></i>) <p> Private slot used to calculate the maintainability indexes for the project. </p> <a NAME="RadonMetricsPlugin.__projectRawMetrics" ID="RadonMetricsPlugin.__projectRawMetrics"></a> <h4>RadonMetricsPlugin.__projectRawMetrics</h4> <b>__projectRawMetrics</b>(<i></i>) <p> Private slot used to calculate raw code metrics for the project. </p> <a NAME="RadonMetricsPlugin.__projectShowMenu" ID="RadonMetricsPlugin.__projectShowMenu"></a> <h4>RadonMetricsPlugin.__projectShowMenu</h4> <b>__projectShowMenu</b>(<i>menuName, menu</i>) <p> Private slot called, when the the project menu or a submenu is about to be shown. </p> <dl> <dt><i>menuName</i> (str)</dt> <dd> name of the menu to be shown </dd> <dt><i>menu</i> (QMenu)</dt> <dd> reference to the menu </dd> </dl> <a NAME="RadonMetricsPlugin.__serviceError" ID="RadonMetricsPlugin.__serviceError"></a> <h4>RadonMetricsPlugin.__serviceError</h4> <b>__serviceError</b>(<i>type_, fn, msg</i>) <p> Private slot handling service errors. </p> <dl> <dt><i>type_</i> (str, one of ["raw", "mi", "cc"])</dt> <dd> type of the calculated metrics </dd> <dt><i>fn</i> (str)</dt> <dd> file name </dd> <dt><i>msg</i> (str)</dt> <dd> message text </dd> </dl> <a NAME="RadonMetricsPlugin.__showRadonVersion" ID="RadonMetricsPlugin.__showRadonVersion"></a> <h4>RadonMetricsPlugin.__showRadonVersion</h4> <b>__showRadonVersion</b>(<i></i>) <p> Private slot to show the version number of the used radon library. </p> <a NAME="RadonMetricsPlugin.activate" ID="RadonMetricsPlugin.activate"></a> <h4>RadonMetricsPlugin.activate</h4> <b>activate</b>(<i></i>) <p> Public method to activate this plug-in. </p> <dl> <dt>Return:</dt> <dd> tuple of None and activation status </dd> </dl> <dl> <dt>Return Type:</dt> <dd> (None, bool) </dd> </dl> <a NAME="RadonMetricsPlugin.batchJobDone" ID="RadonMetricsPlugin.batchJobDone"></a> <h4>RadonMetricsPlugin.batchJobDone</h4> <b>batchJobDone</b>(<i>type_, fx, lang</i>) <p> Public slot handling the completion of a batch job. </p> <dl> <dt><i>type_</i> (str, one of ["raw", "mi", "cc"])</dt> <dd> type of the calculated metrics </dd> <dt><i>fx</i> (str)</dt> <dd> service name </dd> <dt><i>lang</i> (str)</dt> <dd> language </dd> </dl> <a NAME="RadonMetricsPlugin.cancelComplexityBatch" ID="RadonMetricsPlugin.cancelComplexityBatch"></a> <h4>RadonMetricsPlugin.cancelComplexityBatch</h4> <b>cancelComplexityBatch</b>(<i></i>) <p> Public method to cancel all batch jobs. </p> <a NAME="RadonMetricsPlugin.cancelMaintainabilityIndexBatch" ID="RadonMetricsPlugin.cancelMaintainabilityIndexBatch"></a> <h4>RadonMetricsPlugin.cancelMaintainabilityIndexBatch</h4> <b>cancelMaintainabilityIndexBatch</b>(<i></i>) <p> Public method to cancel all batch jobs. </p> <a NAME="RadonMetricsPlugin.cancelRawMetricsBatch" ID="RadonMetricsPlugin.cancelRawMetricsBatch"></a> <h4>RadonMetricsPlugin.cancelRawMetricsBatch</h4> <b>cancelRawMetricsBatch</b>(<i></i>) <p> Public method to cancel all batch jobs. </p> <a NAME="RadonMetricsPlugin.cyclomaticComplexity" ID="RadonMetricsPlugin.cyclomaticComplexity"></a> <h4>RadonMetricsPlugin.cyclomaticComplexity</h4> <b>cyclomaticComplexity</b>(<i>lang, filename, source</i>) <p> Public method to prepare cyclomatic complexity calculation on one Python source file. </p> <dl> <dt><i>lang</i> (str or None)</dt> <dd> language of the file or None to determine by internal algorithm </dd> <dt><i>filename</i> (str)</dt> <dd> source filename </dd> <dt><i>source</i> (str)</dt> <dd> string containing the code </dd> </dl> <a NAME="RadonMetricsPlugin.cyclomaticComplexityBatch" ID="RadonMetricsPlugin.cyclomaticComplexityBatch"></a> <h4>RadonMetricsPlugin.cyclomaticComplexityBatch</h4> <b>cyclomaticComplexityBatch</b>(<i>argumentsList</i>) <p> Public method to prepare cyclomatic complexity calculation on multiple Python source files. </p> <dl> <dt><i>argumentsList</i> ((str, str))</dt> <dd> list of arguments tuples with each tuple containing filename and source </dd> </dl> <a NAME="RadonMetricsPlugin.deactivate" ID="RadonMetricsPlugin.deactivate"></a> <h4>RadonMetricsPlugin.deactivate</h4> <b>deactivate</b>(<i></i>) <p> Public method to deactivate this plug-in. </p> <a NAME="RadonMetricsPlugin.maintainabilityIndex" ID="RadonMetricsPlugin.maintainabilityIndex"></a> <h4>RadonMetricsPlugin.maintainabilityIndex</h4> <b>maintainabilityIndex</b>(<i>lang, filename, source</i>) <p> Public method to prepare maintainability index calculation on one Python source file. </p> <dl> <dt><i>lang</i> (str or None)</dt> <dd> language of the file or None to determine by internal algorithm </dd> <dt><i>filename</i> (str)</dt> <dd> source filename </dd> <dt><i>source</i> (str)</dt> <dd> string containing the code </dd> </dl> <a NAME="RadonMetricsPlugin.maintainabilityIndexBatch" ID="RadonMetricsPlugin.maintainabilityIndexBatch"></a> <h4>RadonMetricsPlugin.maintainabilityIndexBatch</h4> <b>maintainabilityIndexBatch</b>(<i>argumentsList</i>) <p> Public method to prepare maintainability index calculation on multiple Python source files. </p> <dl> <dt><i>argumentsList</i> ((str, str))</dt> <dd> list of arguments tuples with each tuple containing filename and source </dd> </dl> <a NAME="RadonMetricsPlugin.metricsCalculationDone" ID="RadonMetricsPlugin.metricsCalculationDone"></a> <h4>RadonMetricsPlugin.metricsCalculationDone</h4> <b>metricsCalculationDone</b>(<i>type_, filename, result</i>) <p> Public slot to dispatch the result. </p> <dl> <dt><i>type_</i> (str, one of ["raw", "mi", "cc"])</dt> <dd> type of the calculated metrics </dd> <dt><i>filename</i> (str)</dt> <dd> name of the file the results belong to </dd> <dt><i>result</i> (dict)</dt> <dd> result dictionary </dd> </dl> <a NAME="RadonMetricsPlugin.rawMetrics" ID="RadonMetricsPlugin.rawMetrics"></a> <h4>RadonMetricsPlugin.rawMetrics</h4> <b>rawMetrics</b>(<i>lang, filename, source</i>) <p> Public method to prepare raw code metrics calculation on one Python source file. </p> <dl> <dt><i>lang</i> (str or None)</dt> <dd> language of the file or None to determine by internal algorithm </dd> <dt><i>filename</i> (str)</dt> <dd> source filename </dd> <dt><i>source</i> (str)</dt> <dd> string containing the code </dd> </dl> <a NAME="RadonMetricsPlugin.rawMetricsBatch" ID="RadonMetricsPlugin.rawMetricsBatch"></a> <h4>RadonMetricsPlugin.rawMetricsBatch</h4> <b>rawMetricsBatch</b>(<i>argumentsList</i>) <p> Public method to prepare raw code metrics calculation on multiple Python source files. </p> <dl> <dt><i>argumentsList</i> ((str, str))</dt> <dd> list of arguments tuples with each tuple containing filename and source </dd> </dl> <a NAME="RadonMetricsPlugin.serviceErrorPy3" ID="RadonMetricsPlugin.serviceErrorPy3"></a> <h4>RadonMetricsPlugin.serviceErrorPy3</h4> <b>serviceErrorPy3</b>(<i>type_, fx, lang, fn, msg</i>) <p> Public slot handling service errors for Python 3. </p> <dl> <dt><i>type_</i> (str, one of ["raw", "mi", "cc"])</dt> <dd> type of the calculated metrics </dd> <dt><i>fx</i> (str)</dt> <dd> service name </dd> <dt><i>lang</i> (str)</dt> <dd> language </dd> <dt><i>fn</i> (str)</dt> <dd> file name </dd> <dt><i>msg</i> (str)</dt> <dd> message text </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> <hr /> <a NAME="installDependencies" ID="installDependencies"></a> <h2>installDependencies</h2> <b>installDependencies</b>(<i>pipInstall</i>) <p> Function to install dependencies of this plug-in. </p> <dl> <dt><i>pipInstall</i> (function)</dt> <dd> function to be called with a list of package names. </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>