2020-09-24 13:47:11 +00:00
<!DOCTYPE html>
< html class = "writer-html5" lang = "en" >
< head >
< meta charset = "utf-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title > FAQ — MO2 Python Plugin API 2.3rc1 documentation</ title >
< link rel = "stylesheet" href = "_static/css/theme.css" type = "text/css" />
< link rel = "stylesheet" href = "_static/pygments.css" type = "text/css" />
< link rel = "stylesheet" href = "_static/graphviz.css" type = "text/css" />
2020-09-24 14:17:15 +00:00
< link rel = "shortcut icon" href = "_static/mo2.ico" />
2020-09-24 13:47:11 +00:00
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
< script type = "text/javascript" id = "documentation_options" data-url_root = "./" src = "_static/documentation_options.js" ></ script >
< script src = "_static/jquery.js" ></ script >
< script src = "_static/underscore.js" ></ script >
< script src = "_static/doctools.js" ></ script >
< script src = "_static/language_data.js" ></ script >
< script type = "text/javascript" src = "_static/js/theme.js" ></ script >
< link rel = "index" title = "Index" href = "genindex.html" />
< link rel = "search" title = "Search" href = "search.html" />
< link rel = "next" title = "mobase API" href = "mobase.html" />
< link rel = "prev" title = "Writing Plugins" href = "writing-plugins.html" />
</ head >
< body class = "wy-body-for-nav" >
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side" >
< div class = "wy-side-scroll" >
< div class = "wy-side-nav-search" >
< a href = "index.html" class = "icon icon-home" alt = "Documentation Home" > MO2 Python Plugin API
</ a >
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" />
< input type = "hidden" name = "check_keywords" value = "yes" />
< input type = "hidden" name = "area" value = "default" />
</ form >
</ div >
</ div >
< div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "main navigation" >
< p class = "caption" >< span class = "caption-text" > Contents:</ span ></ p >
< ul class = "current" >
< li class = "toctree-l1" >< a class = "reference internal" href = "setup-tools.html" > Setting up the environment</ a >< ul >
< li class = "toctree-l2" >< a class = "reference internal" href = "setup-tools.html#required-tools" > Required tools</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "setup-tools.html#preparation" > Preparation</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "setup-tools.html#get-the-mobase-stubs" > 1. Get the < code class = "docutils literal notranslate" >< span class = "pre" > mobase</ span ></ code > stubs</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "setup-tools.html#configure-visual-studio-code-for-mobase" > 2. Configure Visual Studio Code for < code class = "docutils literal notranslate" >< span class = "pre" > mobase</ span ></ code ></ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "setup-tools.html#configure-mypy-to-find-the-mobase-stubs" > 3. Configure < code class = "docutils literal notranslate" >< span class = "pre" > mypy</ span ></ code > to find the < code class = "docutils literal notranslate" >< span class = "pre" > mobase</ span ></ code > stubs</ a ></ li >
</ ul >
</ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "setup-tools.html#testing-the-setup" > Testing the setup</ a ></ li >
</ ul >
</ li >
< li class = "toctree-l1" >< a class = "reference internal" href = "plugin-types.html" > Type of Plugins</ a >< ul >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#installers" > Installers</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#previewers" > Previewers</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#mod-page" > Mod Page</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#game" > Game</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#tool" > Tool</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#proxies" > Proxies</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#free-plugins" >< em > Free Plugins</ em ></ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "plugin-types.html#extension-interfaces" > Extension Interfaces</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "plugin-types.html#diagnose" > Diagnose</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "plugin-types.html#file-mappings" > File Mappings</ a ></ li >
</ ul >
</ li >
</ ul >
</ li >
< li class = "toctree-l1" >< a class = "reference internal" href = "writing-plugins.html" > Writing Plugins</ a >< ul >
< li class = "toctree-l2" >< a class = "reference internal" href = "writing-plugins.html#getting-started" > Getting started</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "writing-plugins.html#single-file-plugins" > Single file plugins</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "writing-plugins.html#module-plugins" > Module Plugins</ a ></ li >
</ ul >
</ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "writing-plugins.html#writing-the-plugin" > Writing the plugin</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "writing-plugins.html#iplugin-interface" >< code class = "docutils literal notranslate" >< span class = "pre" > IPlugin</ span ></ code > interface</ a ></ li >
</ ul >
</ li >
2020-10-07 18:49:09 +00:00
< li class = "toctree-l2" >< a class = "reference internal" href = "writing-plugins.html#examples" > Examples</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "writing-plugins.html#tutorial-plugins" > Tutorial Plugins</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "writing-plugins.html#official-plugins" > Official Plugins</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "writing-plugins.html#unofficial-plugins" > Unofficial Plugins</ a ></ li >
</ ul >
</ li >
2020-09-24 13:47:11 +00:00
</ ul >
</ li >
< li class = "toctree-l1 current" >< a class = "current reference internal" href = "#" > FAQ</ a >< ul >
< li class = "toctree-l2" >< a class = "reference internal" href = "#why-is-mo2-throwing-an-exception-when-i-try-to-create-a-type-inheriting-one-of-mo2-class" > 1. Why is MO2 throwing an exception when I try to create a type inheriting one of MO2 class?</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "#how-can-i-be-sure-to-implement-all-the-required-methods-when-creating-a-plugin" > 2. How can I be sure to implement all the required methods when creating a plugin?</ a ></ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "#why-are-my-isinstance-x-qobject-and-isinstance-y-qwidget-not-working" > 3. Why are my < code class = "docutils literal notranslate" >< span class = "pre" > isinstance(x,</ span > < span class = "pre" > QObject)</ span ></ code > and < code class = "docutils literal notranslate" >< span class = "pre" > isinstance(y,</ span > < span class = "pre" > QWidget)</ span ></ code > not working?</ a ></ li >
</ ul >
</ li >
< li class = "toctree-l1" >< a class = "reference internal" href = "mobase.html" >< code class = "docutils literal notranslate" >< span class = "pre" > mobase</ span ></ code > API</ a >< ul >
< li class = "toctree-l2" >< a class = "reference internal" href = "mobase.html#functions" > Functions</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.getFileVersion.html" > getFileVersion</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.getIconForExecutable.html" > getIconForExecutable</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.getProductVersion.html" > getProductVersion</ a ></ li >
</ ul >
</ li >
< li class = "toctree-l2" >< a class = "reference internal" href = "mobase.html#classes" > Classes</ a >< ul >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.BSAInvalidation.html" > BSAInvalidation</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.DataArchives.html" > DataArchives</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ExecutableForcedLoadSetting.html" > ExecutableForcedLoadSetting</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ExecutableInfo.html" > ExecutableInfo</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.FileInfo.html" > FileInfo</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.FileTreeEntry.html" > FileTreeEntry</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.GamePlugins.html" > GamePlugins</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.GuessQuality.html" > GuessQuality</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.GuessedString.html" > GuessedString</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IDownloadManager.html" > IDownloadManager</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IFileTree.html" > IFileTree</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IInstallationManager.html" > IInstallationManager</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IModInterface.html" > IModInterface</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IModList.html" > IModList</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IModRepositoryBridge.html" > IModRepositoryBridge</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IOrganizer.html" > IOrganizer</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPlugin.html" > IPlugin</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginDiagnose.html" > IPluginDiagnose</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginFileMapper.html" > IPluginFileMapper</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginGame.html" > IPluginGame</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginInstaller.html" > IPluginInstaller</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginInstallerCustom.html" > IPluginInstallerCustom</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginInstallerSimple.html" > IPluginInstallerSimple</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginList.html" > IPluginList</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginModPage.html" > IPluginModPage</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginPreview.html" > IPluginPreview</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IPluginTool.html" > IPluginTool</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.IProfile.html" > IProfile</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ISaveGame.html" > ISaveGame</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ISaveGameInfoWidget.html" > ISaveGameInfoWidget</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.InstallResult.html" > InstallResult</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.InterfaceNotImplemented.html" > InterfaceNotImplemented</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.LoadOrderMechanism.html" > LoadOrderMechanism</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.LocalSavegames.html" > LocalSavegames</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.Mapping.html" > Mapping</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ModDataChecker.html" > ModDataChecker</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ModDataContent.html" > ModDataContent</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ModRepositoryFileInfo.html" > ModRepositoryFileInfo</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ModState.html" > ModState</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.PluginSetting.html" > PluginSetting</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.PluginState.html" > PluginState</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ProfileSetting.html" > ProfileSetting</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ReleaseType.html" > ReleaseType</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.SaveGameInfo.html" > SaveGameInfo</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.ScriptExtender.html" > ScriptExtender</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.SortMechanism.html" > SortMechanism</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.UnmanagedMods.html" > UnmanagedMods</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.VersionInfo.html" > VersionInfo</ a ></ li >
< li class = "toctree-l3" >< a class = "reference internal" href = "api/mobase.VersionScheme.html" > VersionScheme</ a ></ li >
</ ul >
</ li >
</ ul >
</ li >
</ ul >
</ div >
</ div >
</ nav >
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" >
< nav class = "wy-nav-top" aria-label = "top navigation" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" ></ i >
< a href = "index.html" > MO2 Python Plugin API</ a >
</ nav >
< div class = "wy-nav-content" >
< div class = "rst-content" >
< div role = "navigation" aria-label = "breadcrumbs navigation" >
< ul class = "wy-breadcrumbs" >
< li >< a href = "index.html" class = "icon icon-home" ></ a > » </ li >
< li > FAQ</ li >
< li class = "wy-breadcrumbs-aside" >
< a href = "_sources/faq.rst.txt" rel = "nofollow" > View page source</ a >
</ li >
</ ul >
< hr />
</ div >
< div role = "main" class = "document" itemscope = "itemscope" itemtype = "http://schema.org/Article" >
< div itemprop = "articleBody" >
< div class = "section" id = "faq" >
< h1 > FAQ< a class = "headerlink" href = "#faq" title = "Permalink to this headline" > ΒΆ</ a ></ h1 >
< div class = "toctree-wrapper compound" >
</ div >
< div class = "section" id = "why-is-mo2-throwing-an-exception-when-i-try-to-create-a-type-inheriting-one-of-mo2-class" >
< h2 > 1. Why is MO2 throwing an exception when I try to create a type inheriting one of MO2 class?< a class = "headerlink" href = "#why-is-mo2-throwing-an-exception-when-i-try-to-create-a-type-inheriting-one-of-mo2-class" title = "Permalink to this headline" > ΒΆ</ a ></ h2 >
< p > This often happens if you forget to call < code class = "docutils literal notranslate" >< span class = "pre" > super().__init__()</ span ></ code > with the right arguments.
Even if the list of arguments is empty (as in the example), it must be called due to a βbugβ
in < code class = "docutils literal notranslate" >< span class = "pre" > boost::python</ span ></ code > :</ p >
< div class = "highlight-python notranslate" >< div class = "highlight" >< pre >< span ></ span >< span class = "k" > class</ span > < span class = "nc" > MySaveGame</ span >< span class = "p" > (</ span >< span class = "n" > mobase</ span >< span class = "o" > .</ span >< span class = "n" > ISaveGame</ span >< span class = "p" > ):</ span >
< span class = "k" > def</ span > < span class = "fm" > __init__</ span >< span class = "p" > (</ span >< span class = "bp" > self</ span >< span class = "p" > ):</ span >
< span class = "nb" > super</ span >< span class = "p" > ()</ span >< span class = "o" > .</ span >< span class = "fm" > __init__</ span >< span class = "p" > ()</ span > < span class = "c1" > # Mandatory!</ span >
</ pre ></ div >
</ div >
</ div >
< div class = "section" id = "how-can-i-be-sure-to-implement-all-the-required-methods-when-creating-a-plugin" >
< h2 > 2. How can I be sure to implement all the required methods when creating a plugin?< a class = "headerlink" href = "#how-can-i-be-sure-to-implement-all-the-required-methods-when-creating-a-plugin" title = "Permalink to this headline" > ΒΆ</ a ></ h2 >
< p > It is kind of annoying to create a MO2 python plugin that kind of works and have it crash
at some point simply because there plugin is missing a function implementation.
You can have < code class = "docutils literal notranslate" >< span class = "pre" > mypy</ span ></ code > warn you for such issue by typing the < code class = "docutils literal notranslate" >< span class = "pre" > createPlugin</ span ></ code > or < code class = "docutils literal notranslate" >< span class = "pre" > createPlugins</ span ></ code >
functions:</ p >
< div class = "highlight-python notranslate" >< div class = "highlight" >< pre >< span ></ span >< span class = "kn" > import</ span > < span class = "nn" > typing</ span >
< span class = "c1" > # A plugin that is missing something (e.g. display()).</ span >
< span class = "k" > class</ span > < span class = "nc" > MyPlugin</ span >< span class = "p" > (</ span >< span class = "n" > mobase</ span >< span class = "o" > .</ span >< span class = "n" > IPluginTool</ span >< span class = "p" > ):</ span > < span class = "o" > ...</ span >
< span class = "c1" > # If you type-hint `createPlugin` by adding `-> mobase.IPlugin`,</ span >
< span class = "c1" > # `mypy` will warn you that `MyPlugin` is an incomplete class.</ span >
< span class = "k" > def</ span > < span class = "nf" > createPlugin</ span >< span class = "p" > ()</ span > < span class = "o" > -> </ span > < span class = "n" > mobase</ span >< span class = "o" > .</ span >< span class = "n" > IPlugin</ span >< span class = "p" > :</ span >
< span class = "k" > return</ span > < span class = "n" > MyPlugin</ span >< span class = "p" > ()</ span >
< span class = "c1" > # You can also type-hint `createPlugins`:</ span >
< span class = "k" > def</ span > < span class = "nf" > createPlugins</ span >< span class = "p" > ()</ span > < span class = "o" > -> </ span > < span class = "n" > typing</ span >< span class = "o" > .</ span >< span class = "n" > List</ span >< span class = "p" > [</ span >< span class = "n" > mobase</ span >< span class = "o" > .</ span >< span class = "n" > IPlugin</ span >< span class = "p" > ]:</ span >
< span class = "k" > return</ span > < span class = "p" > [</ span >< span class = "n" > MyPlugin</ span >< span class = "p" > ()]</ span >
</ pre ></ div >
</ div >
</ div >
< div class = "section" id = "why-are-my-isinstance-x-qobject-and-isinstance-y-qwidget-not-working" >
< h2 > 3. Why are my < code class = "docutils literal notranslate" >< span class = "pre" > isinstance(x,</ span > < span class = "pre" > QObject)</ span ></ code > and < code class = "docutils literal notranslate" >< span class = "pre" > isinstance(y,</ span > < span class = "pre" > QWidget)</ span ></ code > not working?< a class = "headerlink" href = "#why-are-my-isinstance-x-qobject-and-isinstance-y-qwidget-not-working" title = "Permalink to this headline" > ΒΆ</ a ></ h2 >
< p > Some classes from < code class = "docutils literal notranslate" >< span class = "pre" > mobase</ span ></ code > are said to inherit < code class = "docutils literal notranslate" >< span class = "pre" > QObject</ span ></ code > and < code class = "docutils literal notranslate" >< span class = "pre" > QWidget</ span ></ code > in the
stubs, such as < a class = "reference internal" href = "api/mobase.IDownloadManager.html#mobase.IDownloadManager" title = "mobase.IDownloadManager" >< code class = "xref py py-class docutils literal notranslate" >< span class = "pre" > mobase.IDownloadManager</ span ></ code ></ a > .
This is not the case in practice due to limitation in Python and < code class = "docutils literal notranslate" >< span class = "pre" > boost::python</ span ></ code > .
The bases are in the stubs to allow for auto-completion and typing, which is then
simulated in the real < code class = "docutils literal notranslate" >< span class = "pre" > mobase</ span ></ code > by overriding < code class = "docutils literal notranslate" >< span class = "pre" > __getattr__</ span ></ code > and delegating to
the underlying < code class = "docutils literal notranslate" >< span class = "pre" > QObject</ span ></ code > or < code class = "docutils literal notranslate" >< span class = "pre" > QWidget</ span ></ code > .</ p >
</ div >
</ div >
</ div >
</ div >
< footer >
< div class = "rst-footer-buttons" role = "navigation" aria-label = "footer navigation" >
< a href = "mobase.html" class = "btn btn-neutral float-right" title = "mobase API" accesskey = "n" rel = "next" > Next < span class = "fa fa-arrow-circle-right" ></ span ></ a >
< a href = "writing-plugins.html" class = "btn btn-neutral float-left" title = "Writing Plugins" accesskey = "p" rel = "prev" >< span class = "fa fa-arrow-circle-left" ></ span > Previous</ a >
</ div >
< hr />
< div role = "contentinfo" >
< p >
© Copyright 2020, Holt59
</ p >
</ div >
Built with < a href = "http://sphinx-doc.org/" > Sphinx</ a > using a
< a href = "https://github.com/rtfd/sphinx_rtd_theme" > theme</ a >
provided by < a href = "https://readthedocs.org" > Read the Docs</ a > .
</ footer >
</ div >
</ div >
</ section >
</ div >
< script type = "text/javascript" >
jQuery ( function () {
SphinxRtdTheme . Navigation . enable ( true );
});
</ script >
</ body >
</ html >