<liclass="toctree-l3"><aclass="reference internal"href="../setup-tools.html#get-the-mobase-stubs">1. Get the <codeclass="docutils literal notranslate"><spanclass="pre">mobase</span></code> stubs</a></li>
<liclass="toctree-l3"><aclass="reference internal"href="../setup-tools.html#configure-visual-studio-code-for-mobase">2. Configure Visual Studio Code for <codeclass="docutils literal notranslate"><spanclass="pre">mobase</span></code></a></li>
<liclass="toctree-l3"><aclass="reference internal"href="../setup-tools.html#configure-mypy-to-find-the-mobase-stubs">3. Configure <codeclass="docutils literal notranslate"><spanclass="pre">mypy</span></code> to find the <codeclass="docutils literal notranslate"><spanclass="pre">mobase</span></code> stubs</a></li>
</ul>
</li>
<liclass="toctree-l2"><aclass="reference internal"href="../setup-tools.html#testing-the-setup">Testing the setup</a></li>
</ul>
</li>
<liclass="toctree-l1"><aclass="reference internal"href="../plugin-types.html">Type of Plugins</a><ul>
<liclass="toctree-l2"><aclass="reference internal"href="../faq.html#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>
<liclass="toctree-l2"><aclass="reference internal"href="../faq.html#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>
<liclass="toctree-l2"><aclass="reference internal"href="../faq.html#why-are-my-isinstance-x-qobject-and-isinstance-y-qwidget-not-working">3. Why are my <codeclass="docutils literal notranslate"><spanclass="pre">isinstance(x,</span><spanclass="pre">QObject)</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">isinstance(y,</span><spanclass="pre">QWidget)</span></code> not working?</a></li>
<h1>IFileTree<aclass="headerlink"href="#ifiletree"title="Permalink to this headline">¶</a></h1>
<dlclass="class">
<dtid="mobase.IFileTree">
<emclass="property">class </em><codeclass="sig-prename descclassname">mobase.</code><codeclass="sig-name descname">IFileTree</code><aclass="headerlink"href="#mobase.IFileTree"title="Permalink to this definition">¶</a></dt>
<td><p>Walk this tree, calling the given function for each entry in it.</p></td>
</tr>
</tbody>
</table>
<pclass="rubric">Attributes Documentation</p>
<dlclass="attribute">
<dtid="mobase.IFileTree.CONTINUE">
<codeclass="sig-name descname">CONTINUE</code><emclass="property">: IFileTree.WalkReturn</em><emclass="property"> = Ellipsis</em><aclass="headerlink"href="#mobase.IFileTree.CONTINUE"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="mobase.IFileTree.FAIL_IF_EXISTS">
<codeclass="sig-name descname">FAIL_IF_EXISTS</code><emclass="property">: IFileTree.InsertPolicy</em><emclass="property"> = Ellipsis</em><aclass="headerlink"href="#mobase.IFileTree.FAIL_IF_EXISTS"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="mobase.IFileTree.MERGE">
<codeclass="sig-name descname">MERGE</code><emclass="property">: IFileTree.InsertPolicy</em><emclass="property"> = Ellipsis</em><aclass="headerlink"href="#mobase.IFileTree.MERGE"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="mobase.IFileTree.REPLACE">
<codeclass="sig-name descname">REPLACE</code><emclass="property">: IFileTree.InsertPolicy</em><emclass="property"> = Ellipsis</em><aclass="headerlink"href="#mobase.IFileTree.REPLACE"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="mobase.IFileTree.SKIP">
<codeclass="sig-name descname">SKIP</code><emclass="property">: IFileTree.WalkReturn</em><emclass="property"> = Ellipsis</em><aclass="headerlink"href="#mobase.IFileTree.SKIP"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dlclass="attribute">
<dtid="mobase.IFileTree.STOP">
<codeclass="sig-name descname">STOP</code><emclass="property">: IFileTree.WalkReturn</em><emclass="property"> = Ellipsis</em><aclass="headerlink"href="#mobase.IFileTree.STOP"title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<pclass="rubric">Methods Documentation</p>
<dlclass="method">
<dtid="mobase.IFileTree.addDirectory">
<codeclass="sig-name descname">addDirectory</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.addDirectory"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new directory tree under this tree.</p>
<p>This method will create missing folders in the given path and will
not fail if the directory already exists but will fail if the given
path contains “.” or “..”.
This method invalidates iterators to this tree and all the subtrees
present in the given path.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>path</strong>– Path to the directory to create.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>An IFileTree corresponding to the created directory.</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>RuntimeError</strong>– If the directory could not be created.</p>
<codeclass="sig-name descname">addFile</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em>, <emclass="sig-param">replace_if_exists=False</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.addFile"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new file directly under this tree.</p>
<p>This method will fail if the file already exists and <cite>replace_if_exists</cite> is <cite>False</cite>.
This method invalidates iterators to this tree and all the subtrees present in the
given path.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>path</strong>– Path to the file to create.</p></li>
<li><p><strong>replace_if_exists</strong>– If True and an entry already exists at the given location, it will be replaced by a new entry. This will replace both files and directories.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A FileTreeEntry corresponding to the created file.</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>RuntimeError</strong>– If the file could not be created.</p>
<codeclass="sig-name descname">clear</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.clear"title="Permalink to this definition">¶</a></dt>
<dd><p>Delete (detach) all the entries from this tree.</p>
<p>This method will go through the entries in this tree and stop at the first
entry that cannot be deleted, this means that the tree can be partially cleared.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p>True if all entries have been detached, False otherwise.</p>
<codeclass="sig-name descname">copy</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">path=''</em>, <emclass="sig-param">policy=<InsertPolicy.FAIL_IF_EXISTS: Ellipsis></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.copy"title="Permalink to this definition">¶</a></dt>
<dd><p>Move the given entry to the given path under this tree.</p>
<p>The entry must not be a parent tree of this tree. This method can also be used
to rename entries.</p>
<p>If the insert policy if FAIL_IF_EXISTS, the call will fail if an entry
at the same location already exists. If the policy is REPLACE, an existing
entry will be replaced. If MERGE, the entry will be merged with the existing
one (if the entry is a file, and a file exists, the file will be replaced).</p>
<p>This method invalidates iterator to this tree, to the parent tree of the given
entry, and to subtrees of this tree if the insert policy is MERGE.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong>– Entry to copy.</p></li>
<li><p><strong>path</strong>– The path to copy the entry to. If the path ends with / or , the entry will be copied in the corresponding directory instead of replacing it. If the
given path is empty (<cite>“”</cite>), the entry is copied directly under this tree.</p></li>
<li><p><strong>policy</strong>– Policy to use to resolve conflicts.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The new entry (copy of the specified entry).</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>RuntimeError</strong>– If the entry could not be copied.</p>
<codeclass="sig-name descname">createOrphanTree</code><spanclass="sig-paren">(</span><emclass="sig-param">name=''</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.createOrphanTree"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new orphan empty tree.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>name</strong>– Name of the tree.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>A new tree without any parent.</p>
<codeclass="sig-name descname">exists</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em>, <emclass="sig-param">type=<FileTypes.DIRECTORY: Ellipsis></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.exists"title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the given entry exists.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>path</strong>– Path to the entry, separated by / or .</p></li>
<li><p><strong>type</strong>– The type of the entry to check.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>True if the entry was found, False otherwise.</p>
<codeclass="sig-name descname">find</code><spanclass="sig-paren">(</span><emclass="sig-param">path</em>, <emclass="sig-param">type=<FileTypes.DIRECTORY: Ellipsis></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.find"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve the given entry.</p>
<p>If no entry exists at the given path, or if the entry is not of the right
type, <cite>None</cite> is returned.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>path</strong>– Path to the entry, separated by / or .</p></li>
<li><p><strong>type</strong>– The type of the entry to check.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The entry at the given location, or <cite>None</cite> if the entry was not found or</p>
<codeclass="sig-name descname">insert</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">policy=<InsertPolicy.FAIL_IF_EXISTS: Ellipsis></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.insert"title="Permalink to this definition">¶</a></dt>
<dd><p>Insert the given entry in this tree, removing it from its
previouis parent.</p>
<p>The entry must not be this tree or a parent entry of this tree.</p>
<blockquote>
<div><ulclass="simple">
<li><p>If the insert policy if <cite>FAIL_IF_EXISTS</cite>, the call will fail if an entry
with the same name already exists.</p></li>
<li><p>If the policy is <cite>REPLACE</cite>, an existing entry will be replaced by the given entry.</p></li>
<li><p>If the policy is <cite>MERGE</cite>:</p>
<ul>
<li><p>If there is no entry with the same name, the new entry is inserted.</p></li>
<li><p>If there is an entry with the same name:</p>
<ul>
<li><p>If both entries are files, the old file is replaced by the given entry.</p></li>
<li><p>If both entries are directories, a merge is performed as if using merge().</p></li>
<li><p>Otherwize the insertion fails (two entries with different types).</p></li>
</ul>
</li>
</ul>
</li>
</ul>
</div></blockquote>
<p>This method invalidates iterator to this tree, to the parent tree of the given
entry, and to subtrees of this tree if the insert policy is MERGE.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong>– Entry to insert.</p></li>
<li><p><strong>policy</strong>– Policy to use to resolve conflicts.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>True if the entry was insert, False otherwise.</p>
<codeclass="sig-name descname">merge</code><spanclass="sig-paren">(</span><emclass="sig-param">other</em>, <emclass="sig-param">overwrites=False</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.merge"title="Permalink to this definition">¶</a></dt>
<dd><p>Merge the given tree with this tree, i.e., insert all entries
of the given tree into this tree.</p>
<p>The tree must not be this tree or a parent entry of this tree. Files present in both tree
will be replaced by files in the given tree. After a merge, the source tree will be
empty but still attached to its parent.</p>
<p>If <cite>overwrites</cite> is <cite>True</cite>, a map from overriden files to new files will be returned.</p>
<p>Note that the merge process makes no distinction between files and directories
when merging: if a directory is present in this tree and a file from source
is in conflict with it, the tree will be removed and the file inserted; if a file
is in this tree and a directory from source is in conflict with it, the file will
be replaced with the directory.</p>
<p>This method invalidates iterators to this tree, all the subtrees under this tree
present in the given path, and all the subtrees of the given source.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>other</strong>– Tree to merge.</p></li>
<li><p><strong>overwrites</strong>– If True, a mapping from overriden files to new files will be returned.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>If <cite>overwrites</cite> is True, a mapping from overriden files to new files, otherwise</p>
</dd>
</dl>
<p>the number of overwritten entries.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>RuntimeError</strong>– If the merge failed.</p>
<codeclass="sig-name descname">move</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">path</em>, <emclass="sig-param">policy=<InsertPolicy.FAIL_IF_EXISTS: Ellipsis></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.move"title="Permalink to this definition">¶</a></dt>
<dd><p>Move the given entry to the given path under this tree.</p>
<p>The entry must not be a parent tree of this tree. This method can also be used
to rename entries.</p>
<p>If the insert policy if FAIL_IF_EXISTS, the call will fail if an entry
at the same location already exists. If the policy is REPLACE, an existing
entry will be replaced. If MERGE, the entry will be merged with the existing
one (if the entry is a file, and a file exists, the file will be replaced).</p>
<p>This method invalidates iterator to this tree, to the parent tree of the given
entry, and to subtrees of this tree if the insert policy is MERGE.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong>– Entry to move.</p></li>
<li><p><strong>path</strong>– The path to move the entry to. If the path ends with / or , the entry will be inserted in the corresponding directory instead of replacing it. If the
given path is empty (<cite>“”</cite>), this is equivalent to <cite>insert()</cite>.</p></li>
<li><p><strong>policy</strong>– Policy to use to resolve conflicts.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>True if the entry was moved correctly, False otherwise.</p>
<codeclass="sig-name descname">pathTo</code><spanclass="sig-paren">(</span><emclass="sig-param">entry</em>, <emclass="sig-param">sep='\\'</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.pathTo"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve the path from this tree to the given entry.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>entry</strong>– The entry to reach, must be in this tree.</p></li>
<li><p><strong>sep</strong>– The type of separator to use to create the path.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The path from this tree to the given entry, including the name of the entry, or</p>
</dd>
</dl>
<p>an empty string if the given entry was not found under this tree.</p>
<codeclass="sig-name descname">remove</code><spanclass="sig-paren">(</span><emclass="sig-param">**kwds</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.remove"title="Permalink to this definition">¶</a></dt>
<dd><p>Helper for @overload to raise when called.</p>
</dd></dl>
<dlclass="method">
<dtid="mobase.IFileTree.removeAll">
<codeclass="sig-name descname">removeAll</code><spanclass="sig-paren">(</span><emclass="sig-param">names</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.removeAll"title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the entries with the given names from the tree.</p>
<p>This method does not recurse into subtrees, so only entries accessible
directly from this tree will be removed. This method invalidates iterators.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>names</strong>– Names of the entries to delete.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The number of deleted entry.</p>
<codeclass="sig-name descname">removeIf</code><spanclass="sig-paren">(</span><emclass="sig-param">filter</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.removeIf"title="Permalink to this definition">¶</a></dt>
<dd><p>Delete entries matching the given predicate from the tree.</p>
<p>This method does not recurse into subtrees, so only entries accessible
directly from this tree will be removed. This method invalidates iterators.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>filter</strong>– Predicate that should return true for entries to delete.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>The number of deleted entry.</p>
<codeclass="sig-name descname">walk</code><spanclass="sig-paren">(</span><emclass="sig-param">callback</em>, <emclass="sig-param">sep='\\'</em><spanclass="sig-paren">)</span><aclass="headerlink"href="#mobase.IFileTree.walk"title="Permalink to this definition">¶</a></dt>
<dd><p>Walk this tree, calling the given function for each entry in it.</p>
<p>The given callback will be called with two parameters: the path from this tree to the given entry
(with a trailing separator, not including the entry name), and the actual entry. The method returns
a <cite>WalkReturn</cite> object to indicates what to do.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>callback</strong>– Method to call for each entry in the tree.</p></li>
<li><p><strong>sep</strong>– Type of separator to use to construct the path.</p></li>