Sat, 05 Dec 2020 17:18:17 +0100
Added the capability to create project specific virtual environments.
<!DOCTYPE html> <html><head> <title>Plugin_Project_Flask.ProjectFlask.Project</title> <meta charset="UTF-8"> <style> body { background: #EDECE6; margin: 0em 1em 10em 1em; color: black; } h1 { color: white; background: #85774A; } h2 { color: white; background: #85774A; } h3 { color: white; background: #9D936E; } h4 { color: white; background: #9D936E; } a { color: #BA6D36; } </style> </head> <body> <a NAME="top" ID="top"></a> <h1>Plugin_Project_Flask.ProjectFlask.Project</h1> <p> Module implementing the Flask project support. </p> <h3>Global Attributes</h3> <table> <tr><td>None</td></tr> </table> <h3>Classes</h3> <table> <tr> <td><a href="#Project">Project</a></td> <td>Class implementing the Flask project support.</td> </tr> </table> <h3>Functions</h3> <table> <tr><td>None</td></tr> </table> <hr /> <hr /> <a NAME="Project" ID="Project"></a> <h2>Project</h2> <p> Class implementing the Flask project support. </p> <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="#Project.__init__">Project</a></td> <td>Constructor</td> </tr> <tr> <td><a href="#Project.__configureFlaskForProject">__configureFlaskForProject</a></td> <td>Private slot to configure the project specific flask parameters.</td> </tr> <tr> <td><a href="#Project.__determineCapabilities">__determineCapabilities</a></td> <td>Private method to determine capabilities provided by supported extensions.</td> </tr> <tr> <td><a href="#Project.__flaskInfo">__flaskInfo</a></td> <td>Private slot to show some info about Flask.</td> </tr> <tr> <td><a href="#Project.__isSuitableForVariant">__isSuitableForVariant</a></td> <td>Private method to test, if a detected command file is suitable for the given Python variant.</td> </tr> <tr> <td><a href="#Project.__runDevelopmentServer">__runDevelopmentServer</a></td> <td>Private slot to start the Flask Web server in development mode.</td> </tr> <tr> <td><a href="#Project.__runPythonShell">__runPythonShell</a></td> <td>Private slot to start a Python console in the app context.</td> </tr> <tr> <td><a href="#Project.__runServer">__runServer</a></td> <td>Private slot to start the Flask Web server.</td> </tr> <tr> <td><a href="#Project.__setDebugEnvironment">__setDebugEnvironment</a></td> <td>Private method to set the virtual environment as the selected debug environment.</td> </tr> <tr> <td><a href="#Project.__setIgnoreVirtualEnvironment">__setIgnoreVirtualEnvironment</a></td> <td>Private method to add an embedded project specific virtual environment to the list of ignore files/directories.</td> </tr> <tr> <td><a href="#Project.__shellProcessFinished">__shellProcessFinished</a></td> <td>Private slot connected to the finished signal.</td> </tr> <tr> <td><a href="#Project.__showDocumentation">__showDocumentation</a></td> <td>Private slot to show the helpviewer with the Flask documentation.</td> </tr> <tr> <td><a href="#Project.__showRoutes">__showRoutes</a></td> <td>Private slot showing all URL dispatch routes.</td> </tr> <tr> <td><a href="#Project.__terminatePythonShell">__terminatePythonShell</a></td> <td>Private method to terminate the current Python console.</td> </tr> <tr> <td><a href="#Project.getApplication">getApplication</a></td> <td>Public method to determine the application name and the respective working directory.</td> </tr> <tr> <td><a href="#Project.getData">getData</a></td> <td>Public method to get data stored in the project store.</td> </tr> <tr> <td><a href="#Project.getFlaskCommand">getFlaskCommand</a></td> <td>Public method to build the Flask command.</td> </tr> <tr> <td><a href="#Project.getFlaskVersionStrings">getFlaskVersionStrings</a></td> <td>Public method to get the Flask, Werkzeug and Python versions as a string.</td> </tr> <tr> <td><a href="#Project.getFullCommand">getFullCommand</a></td> <td>Public method to get the full command for a given command name.</td> </tr> <tr> <td><a href="#Project.getMenu">getMenu</a></td> <td>Public method to get a reference to the requested menu.</td> </tr> <tr> <td><a href="#Project.getMenuNames">getMenuNames</a></td> <td>Public method to get the names of all menus.</td> </tr> <tr> <td><a href="#Project.getVirtualEnvironment">getVirtualEnvironment</a></td> <td>Public method to get the path of the virtual environment.</td> </tr> <tr> <td><a href="#Project.getVirtualenvInterpreter">getVirtualenvInterpreter</a></td> <td>Public method to get the path of the Python interpreter to be used with the current project.</td> </tr> <tr> <td><a href="#Project.hasCapability">hasCapability</a></td> <td>Public method to check, if a capability is available.</td> </tr> <tr> <td><a href="#Project.initActions">initActions</a></td> <td>Public method to define the Flask actions.</td> </tr> <tr> <td><a href="#Project.initMenu">initMenu</a></td> <td>Public method to initialize the Flask menu.</td> </tr> <tr> <td><a href="#Project.newForm">newForm</a></td> <td>Public method to create a new form.</td> </tr> <tr> <td><a href="#Project.prepareRuntimeEnvironment">prepareRuntimeEnvironment</a></td> <td>Public method to prepare a QProcessEnvironment object and determine the appropriate working directory.</td> </tr> <tr> <td><a href="#Project.projectClosed">projectClosed</a></td> <td>Public method to handle the closing of a project.</td> </tr> <tr> <td><a href="#Project.projectClosedHooks">projectClosedHooks</a></td> <td>Public method to remove our hook methods.</td> </tr> <tr> <td><a href="#Project.projectOpenedHooks">projectOpenedHooks</a></td> <td>Public method to add our hook methods.</td> </tr> <tr> <td><a href="#Project.setCapability">setCapability</a></td> <td>Public method to set the availability status of a capability.</td> </tr> <tr> <td><a href="#Project.setData">setData</a></td> <td>Public method to store data in the project store.</td> </tr> <tr> <td><a href="#Project.supportedPythonVariants">supportedPythonVariants</a></td> <td>Public method to get the supported Python variants.</td> </tr> </table> <h3>Static Methods</h3> <table> <tr><td>None</td></tr> </table> <a NAME="Project.__init__" ID="Project.__init__"></a> <h4>Project (Constructor)</h4> <b>Project</b>(<i>plugin, iconSuffix, parent=None</i>) <p> Constructor </p> <dl> <dt><i>plugin</i> (ProjectFlaskPlugin)</dt> <dd> reference to the plugin object </dd> <dt><i>iconSuffix</i> (str)</dt> <dd> suffix for the icons </dd> <dt><i>parent</i> (QObject)</dt> <dd> parent </dd> </dl> <a NAME="Project.__configureFlaskForProject" ID="Project.__configureFlaskForProject"></a> <h4>Project.__configureFlaskForProject</h4> <b>__configureFlaskForProject</b>(<i></i>) <p> Private slot to configure the project specific flask parameters. </p> <a NAME="Project.__determineCapabilities" ID="Project.__determineCapabilities"></a> <h4>Project.__determineCapabilities</h4> <b>__determineCapabilities</b>(<i></i>) <p> Private method to determine capabilities provided by supported extensions. </p> <a NAME="Project.__flaskInfo" ID="Project.__flaskInfo"></a> <h4>Project.__flaskInfo</h4> <b>__flaskInfo</b>(<i></i>) <p> Private slot to show some info about Flask. </p> <a NAME="Project.__isSuitableForVariant" ID="Project.__isSuitableForVariant"></a> <h4>Project.__isSuitableForVariant</h4> <b>__isSuitableForVariant</b>(<i>variant, line0</i>) <p> Private method to test, if a detected command file is suitable for the given Python variant. </p> <dl> <dt><i>variant</i> (str)</dt> <dd> Python variant to test for </dd> <dt><i>line0</i> (str)</dt> <dd> first line of the executable </dd> </dl> <dl> <dt>Returns:</dt> <dd> flag indicating a suitable file was found </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <a NAME="Project.__runDevelopmentServer" ID="Project.__runDevelopmentServer"></a> <h4>Project.__runDevelopmentServer</h4> <b>__runDevelopmentServer</b>(<i></i>) <p> Private slot to start the Flask Web server in development mode. </p> <a NAME="Project.__runPythonShell" ID="Project.__runPythonShell"></a> <h4>Project.__runPythonShell</h4> <b>__runPythonShell</b>(<i></i>) <p> Private slot to start a Python console in the app context. </p> <a NAME="Project.__runServer" ID="Project.__runServer"></a> <h4>Project.__runServer</h4> <b>__runServer</b>(<i>development=False</i>) <p> Private slot to start the Flask Web server. </p> <dl> <dt><i>development</i> (bool)</dt> <dd> flag indicating development mode </dd> </dl> <a NAME="Project.__setDebugEnvironment" ID="Project.__setDebugEnvironment"></a> <h4>Project.__setDebugEnvironment</h4> <b>__setDebugEnvironment</b>(<i></i>) <p> Private method to set the virtual environment as the selected debug environment. </p> <a NAME="Project.__setIgnoreVirtualEnvironment" ID="Project.__setIgnoreVirtualEnvironment"></a> <h4>Project.__setIgnoreVirtualEnvironment</h4> <b>__setIgnoreVirtualEnvironment</b>(<i></i>) <p> Private method to add an embedded project specific virtual environment to the list of ignore files/directories. </p> <a NAME="Project.__shellProcessFinished" ID="Project.__shellProcessFinished"></a> <h4>Project.__shellProcessFinished</h4> <b>__shellProcessFinished</b>(<i></i>) <p> Private slot connected to the finished signal. </p> <a NAME="Project.__showDocumentation" ID="Project.__showDocumentation"></a> <h4>Project.__showDocumentation</h4> <b>__showDocumentation</b>(<i></i>) <p> Private slot to show the helpviewer with the Flask documentation. </p> <a NAME="Project.__showRoutes" ID="Project.__showRoutes"></a> <h4>Project.__showRoutes</h4> <b>__showRoutes</b>(<i></i>) <p> Private slot showing all URL dispatch routes. </p> <a NAME="Project.__terminatePythonShell" ID="Project.__terminatePythonShell"></a> <h4>Project.__terminatePythonShell</h4> <b>__terminatePythonShell</b>(<i></i>) <p> Private method to terminate the current Python console. </p> <a NAME="Project.getApplication" ID="Project.getApplication"></a> <h4>Project.getApplication</h4> <b>getApplication</b>(<i></i>) <p> Public method to determine the application name and the respective working directory. </p> <dl> <dt>Returns:</dt> <dd> tuple containing the working directory and the application name </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (str, str) </dd> </dl> <a NAME="Project.getData" ID="Project.getData"></a> <h4>Project.getData</h4> <b>getData</b>(<i>category, key</i>) <p> Public method to get data stored in the project store. </p> <dl> <dt><i>category</i> (str)</dt> <dd> data category </dd> <dt><i>key</i> (str)</dt> <dd> data key </dd> </dl> <dl> <dt>Returns:</dt> <dd> referenced data </dd> </dl> <dl> <dt>Return Type:</dt> <dd> any </dd> </dl> <a NAME="Project.getFlaskCommand" ID="Project.getFlaskCommand"></a> <h4>Project.getFlaskCommand</h4> <b>getFlaskCommand</b>(<i></i>) <p> Public method to build the Flask command. </p> <dl> <dt>Returns:</dt> <dd> full flask command </dd> </dl> <dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <a NAME="Project.getFlaskVersionStrings" ID="Project.getFlaskVersionStrings"></a> <h4>Project.getFlaskVersionStrings</h4> <b>getFlaskVersionStrings</b>(<i></i>) <p> Public method to get the Flask, Werkzeug and Python versions as a string. </p> <dl> <dt>Returns:</dt> <dd> dictionary containing the Flask, Werkzeug and Python versions </dd> </dl> <dl> <dt>Return Type:</dt> <dd> dict </dd> </dl> <a NAME="Project.getFullCommand" ID="Project.getFullCommand"></a> <h4>Project.getFullCommand</h4> <b>getFullCommand</b>(<i>command, virtualEnvPath=None</i>) <p> Public method to get the full command for a given command name. </p> <dl> <dt><i>command</i> (str)</dt> <dd> command name </dd> <dt><i>virtualEnvPath</i> (str)</dt> <dd> path of the virtual environment </dd> </dl> <dl> <dt>Returns:</dt> <dd> full command </dd> </dl> <dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <a NAME="Project.getMenu" ID="Project.getMenu"></a> <h4>Project.getMenu</h4> <b>getMenu</b>(<i>name</i>) <p> Public method to get a reference to the requested menu. </p> <dl> <dt><i>name</i> (str)</dt> <dd> name of the menu </dd> </dl> <dl> <dt>Returns:</dt> <dd> reference to the menu or None, if no menu with the given name exists </dd> </dl> <dl> <dt>Return Type:</dt> <dd> QMenu or None </dd> </dl> <a NAME="Project.getMenuNames" ID="Project.getMenuNames"></a> <h4>Project.getMenuNames</h4> <b>getMenuNames</b>(<i></i>) <p> Public method to get the names of all menus. </p> <dl> <dt>Returns:</dt> <dd> menu names </dd> </dl> <dl> <dt>Return Type:</dt> <dd> list of str </dd> </dl> <a NAME="Project.getVirtualEnvironment" ID="Project.getVirtualEnvironment"></a> <h4>Project.getVirtualEnvironment</h4> <b>getVirtualEnvironment</b>(<i></i>) <p> Public method to get the path of the virtual environment. </p> <dl> <dt>Returns:</dt> <dd> path of the virtual environment </dd> </dl> <dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <a NAME="Project.getVirtualenvInterpreter" ID="Project.getVirtualenvInterpreter"></a> <h4>Project.getVirtualenvInterpreter</h4> <b>getVirtualenvInterpreter</b>(<i></i>) <p> Public method to get the path of the Python interpreter to be used with the current project. </p> <dl> <dt>Returns:</dt> <dd> path of the Python interpreter </dd> </dl> <dl> <dt>Return Type:</dt> <dd> str </dd> </dl> <a NAME="Project.hasCapability" ID="Project.hasCapability"></a> <h4>Project.hasCapability</h4> <b>hasCapability</b>(<i>key</i>) <p> Public method to check, if a capability is available. </p> <dl> <dt><i>key</i> (str)</dt> <dd> key of the capability to check </dd> </dl> <dl> <dt>Returns:</dt> <dd> flag indicating the availability of the capability </dd> </dl> <dl> <dt>Return Type:</dt> <dd> bool </dd> </dl> <a NAME="Project.initActions" ID="Project.initActions"></a> <h4>Project.initActions</h4> <b>initActions</b>(<i></i>) <p> Public method to define the Flask actions. </p> <a NAME="Project.initMenu" ID="Project.initMenu"></a> <h4>Project.initMenu</h4> <b>initMenu</b>(<i></i>) <p> Public method to initialize the Flask menu. </p> <dl> <dt>Returns:</dt> <dd> the menu generated </dd> </dl> <dl> <dt>Return Type:</dt> <dd> QMenu </dd> </dl> <a NAME="Project.newForm" ID="Project.newForm"></a> <h4>Project.newForm</h4> <b>newForm</b>(<i>dirPath</i>) <p> Public method to create a new form. </p> <dl> <dt><i>dirPath</i> (str)</dt> <dd> full directory path for the new form file </dd> </dl> <a NAME="Project.prepareRuntimeEnvironment" ID="Project.prepareRuntimeEnvironment"></a> <h4>Project.prepareRuntimeEnvironment</h4> <b>prepareRuntimeEnvironment</b>(<i>development=False</i>) <p> Public method to prepare a QProcessEnvironment object and determine the appropriate working directory. </p> <dl> <dt><i>development</i> (bool)</dt> <dd> flag indicating development mode </dd> </dl> <dl> <dt>Returns:</dt> <dd> tuple containing the working directory and a prepared environment object to be used with QProcess </dd> </dl> <dl> <dt>Return Type:</dt> <dd> tuple of (str, QProcessEnvironment) </dd> </dl> <a NAME="Project.projectClosed" ID="Project.projectClosed"></a> <h4>Project.projectClosed</h4> <b>projectClosed</b>(<i></i>) <p> Public method to handle the closing of a project. </p> <a NAME="Project.projectClosedHooks" ID="Project.projectClosedHooks"></a> <h4>Project.projectClosedHooks</h4> <b>projectClosedHooks</b>(<i></i>) <p> Public method to remove our hook methods. </p> <a NAME="Project.projectOpenedHooks" ID="Project.projectOpenedHooks"></a> <h4>Project.projectOpenedHooks</h4> <b>projectOpenedHooks</b>(<i></i>) <p> Public method to add our hook methods. </p> <a NAME="Project.setCapability" ID="Project.setCapability"></a> <h4>Project.setCapability</h4> <b>setCapability</b>(<i>key, available</i>) <p> Public method to set the availability status of a capability. </p> <dl> <dt><i>key</i> (str)</dt> <dd> key of the capability to set </dd> <dt><i>available</i> (bool)</dt> <dd> flag indicating the availability of the capability </dd> </dl> <a NAME="Project.setData" ID="Project.setData"></a> <h4>Project.setData</h4> <b>setData</b>(<i>category, key, value</i>) <p> Public method to store data in the project store. </p> <dl> <dt><i>category</i> (str)</dt> <dd> data category </dd> <dt><i>key</i> (str)</dt> <dd> data key </dd> <dt><i>value</i> (any (serializable type))</dt> <dd> data to be stored </dd> </dl> <a NAME="Project.supportedPythonVariants" ID="Project.supportedPythonVariants"></a> <h4>Project.supportedPythonVariants</h4> <b>supportedPythonVariants</b>(<i></i>) <p> Public method to get the supported Python variants. </p> <dl> <dt>Returns:</dt> <dd> list of supported Python variants </dd> </dl> <dl> <dt>Return Type:</dt> <dd> list of str </dd> </dl> <div align="right"><a href="#top">Up</a></div> <hr /> </body></html>