Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 3510c9e686d39c4057250692cfa9ddee > files > 11

python-yapsy-doc-1.10.2-3.fc18.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>PluginFileLocator &mdash; Yapsy 1.10.2 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '1.10.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="shortcut icon" href="_static/yapsy-favicon.ico"/>
    <link rel="top" title="Yapsy 1.10.2 documentation" href="index.html" />
    <link rel="up" title="Built-in Extensions" href="Extensions.html" />
    <link rel="next" title="IPluginLocator" href="IPluginLocator.html" />
    <link rel="prev" title="FilteredPluginManager" href="FilteredPluginManager.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="IPluginLocator.html" title="IPluginLocator"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="FilteredPluginManager.html" title="FilteredPluginManager"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Yapsy 1.10.2 documentation</a> &raquo;</li>
          <li><a href="Extensions.html" accesskey="U">Built-in Extensions</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-yapsy.PluginFileLocator">
<span id="pluginfilelocator"></span><h1>PluginFileLocator<a class="headerlink" href="#module-yapsy.PluginFileLocator" title="Permalink to this headline">¶</a></h1>
<div class="section" id="role">
<h2>Role<a class="headerlink" href="#role" title="Permalink to this headline">¶</a></h2>
<p>The <tt class="docutils literal"><span class="pre">PluginFileLocator</span></tt> locates plugins when they are accessible via the filesystem.</p>
<p>It&#8217;s default behaviour is to look for text files with the
&#8216;.yapsy-plugin&#8217; extensions and to read the plugin&#8217;s decription in
them.</p>
<div class="section" id="customization">
<h3>Customization<a class="headerlink" href="#customization" title="Permalink to this headline">¶</a></h3>
<p>The behaviour of a <tt class="docutils literal"><span class="pre">PluginFileLocator</span></tt> can be customized by instanciating it with a specific &#8216;analyzer&#8217;.</p>
<p>Two analyzers are already implemented and provided here:</p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">PluginFileAnalyzerWithInfoFile</span></tt></p>
<blockquote>
<div>the default &#8216;analyzer&#8217; that looks for plugin &#8216;info files&#8217; as
text file with a predefined extension. This implements the way
yapsy looks for plugin since version 1.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">PluginFileAnalyzerMathingRegex</span></tt></p>
<blockquote>
<div>look for files matching a regex and considers them as being
the plugin itself.</div></blockquote>
</div></blockquote>
<p>All analyzers must enforce the</p>
<p>It enforces the <tt class="docutils literal"><span class="pre">plugin</span> <span class="pre">locator</span></tt> policy as defined by <tt class="docutils literal"><span class="pre">IPluginLocator</span></tt> and used by <tt class="docutils literal"><span class="pre">PluginManager</span></tt>.</p>
<blockquote>
<div><p><tt class="docutils literal"><span class="pre">info_ext</span></tt></p>
<blockquote>
<div>expects a plugin to be discovered through its <em>plugin info file</em>.
User just needs to provide an extension (without &#8216;.&#8217;) to look
for <em>plugin_info_file</em>.</div></blockquote>
<p><tt class="docutils literal"><span class="pre">regexp</span></tt></p>
<blockquote>
<div>looks for file matching the given regular pattern expression.
User just needs to provide the regular pattern expression.</div></blockquote>
</div></blockquote>
<p>All analyzers must enforce the policy represented by the <tt class="docutils literal"><span class="pre">IPluginFileAnalyzer</span></tt> interface.</p>
<dl class="class">
<dt id="yapsy.PluginFileLocator.IPluginFileAnalyzer">
<em class="property">class </em><tt class="descclassname">yapsy.PluginFileLocator.</tt><tt class="descname">IPluginFileAnalyzer</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.IPluginFileAnalyzer" title="Permalink to this definition">¶</a></dt>
<dd><p>Define the methods expected by PluginFileLocator for its &#8216;analyzer&#8217;.</p>
<dl class="method">
<dt id="yapsy.PluginFileLocator.IPluginFileAnalyzer.getInfosDictFromPlugin">
<tt class="descname">getInfosDictFromPlugin</tt><big>(</big><em>dirpath</em>, <em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.IPluginFileAnalyzer.getInfosDictFromPlugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the extracted plugin informations as a dictionary.
This function ensures that &#8220;name&#8221; and &#8220;path&#8221; are provided.</p>
<p><em>dirpath</em> is the full path to the directory where the plugin file is</p>
<p><em>filename</em> is the name (ie the basename) of the plugin file.</p>
<p>If <em>callback</em> function has not been provided for this strategy,
we use the filename alone to extract minimal informations.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.IPluginFileAnalyzer.isValidPlugin">
<tt class="descname">isValidPlugin</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.IPluginFileAnalyzer.isValidPlugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if the resource found at filename is a valid plugin.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerMathingRegex">
<em class="property">class </em><tt class="descclassname">yapsy.PluginFileLocator.</tt><tt class="descname">PluginFileAnalyzerMathingRegex</tt><big>(</big><em>name</em>, <em>regexp</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerMathingRegex" title="Permalink to this definition">¶</a></dt>
<dd><p>An analyzer that targets plugins decribed by files whose name match a given regex.</p>
<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerMathingRegex.getInfosDictFromPlugin">
<tt class="descname">getInfosDictFromPlugin</tt><big>(</big><em>dirpath</em>, <em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerMathingRegex.getInfosDictFromPlugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the extracted plugin informations as a dictionary.
This function ensures that &#8220;name&#8221; and &#8220;path&#8221; are provided.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerMathingRegex.isValidPlugin">
<tt class="descname">isValidPlugin</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerMathingRegex.isValidPlugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Checks if the given filename is a valid plugin for this Strategy</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile">
<em class="property">class </em><tt class="descclassname">yapsy.PluginFileLocator.</tt><tt class="descname">PluginFileAnalyzerWithInfoFile</tt><big>(</big><em>name</em>, <em>extensions='yapsy-plugin'</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile" title="Permalink to this definition">¶</a></dt>
<dd><p>Consider plugins described by a textual description file.</p>
<p>A plugin is expected to be described by a text file (&#8216;ini&#8217; format) with a specific extension (.yapsy-plugin by default).</p>
<p>This file must contain at least the following information:</p>
<div class="highlight-python"><pre>[Core]
Name = name of the module
Module = relative_path/to/python_file_or_directory</pre>
</div>
<p>Optionnally the description file may also contain the following section (in addition to the above one):</p>
<div class="highlight-python"><pre>[Documentation]
Author = Author Name
Version = Major.minor
Website = url_for_plugin
Description = A simple one-sentence description</pre>
</div>
<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.getInfosDictFromPlugin">
<tt class="descname">getInfosDictFromPlugin</tt><big>(</big><em>dirpath</em>, <em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.getInfosDictFromPlugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the extracted plugin informations as a dictionary.
This function ensures that &#8220;name&#8221; and &#8220;path&#8221; are provided.</p>
<p>If <em>callback</em> function has not been provided for this strategy,
we use the filename alone to extract minimal informations.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.getPluginNameAndModuleFromStream">
<tt class="descname">getPluginNameAndModuleFromStream</tt><big>(</big><em>infoFileObject</em>, <em>candidate_infofile=None</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.getPluginNameAndModuleFromStream" title="Permalink to this definition">¶</a></dt>
<dd><p>Extract the name and module of a plugin from the
content of the info file that describes it and which
is stored in <tt class="docutils literal"><span class="pre">infoFileObject</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Prefer using <tt class="docutils literal"><span class="pre">_extractCorePluginInfo</span></tt>
instead, whenever possible...</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last"><tt class="docutils literal"><span class="pre">infoFileObject</span></tt> must be a file-like object:
either an opened file for instance or a string
buffer wrapped in a StringIO instance as another
example.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last"><tt class="docutils literal"><span class="pre">candidate_infofile</span></tt> must be provided
whenever possible to get better error messages.</p>
</div>
<p>Return a 3-uple with the name of the plugin, its
module and the config_parser used to gather the core
data <em>in a tuple</em>, if the required info could be
localised, else return <tt class="docutils literal"><span class="pre">(None,None,None)</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This is supposed to be used internally by subclasses
and decorators.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.isValidPlugin">
<tt class="descname">isValidPlugin</tt><big>(</big><em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.isValidPlugin" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if it is a valid plugin based on the given plugin info file extension(s).
If several extensions are provided, the first matching will cause the function
to exit successfully.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.setPluginInfoExtension">
<tt class="descname">setPluginInfoExtension</tt><big>(</big><em>extensions</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileAnalyzerWithInfoFile.setPluginInfoExtension" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the extension that will identify a plugin info file.</p>
<p><em>extensions</em> May be a string or a tuple of strings if several extensions are expected.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="yapsy.PluginFileLocator.PluginFileLocator">
<em class="property">class </em><tt class="descclassname">yapsy.PluginFileLocator.</tt><tt class="descname">PluginFileLocator</tt><big>(</big><em>analyzers=None</em>, <em>plugin_info_cls=&lt;class 'yapsy.PluginInfo.PluginInfo'&gt;</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator" title="Permalink to this definition">¶</a></dt>
<dd><p>Locates plugins on the file system using a set of analyzers to
determine what files actually corresponds to plugins.</p>
<p>If more than one analyzer is being used, the first that will discover a
new plugin will avoid other strategies to find it too.</p>
<p>By default each directory set as a &#8220;plugin place&#8221; is scanned
recursively. You can change that by a call to
<tt class="docutils literal"><span class="pre">disableRecursiveScan</span></tt>.</p>
<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.appendAnalyzer">
<tt class="descname">appendAnalyzer</tt><big>(</big><em>analyzer</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.appendAnalyzer" title="Permalink to this definition">¶</a></dt>
<dd><p>Append an analyzer to the existing list.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.disableRecursiveScan">
<tt class="descname">disableRecursiveScan</tt><big>(</big><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.disableRecursiveScan" title="Permalink to this definition">¶</a></dt>
<dd><p>Disable recursive scan of the directories given as plugin places.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.gatherCorePluginInfo">
<tt class="descname">gatherCorePluginInfo</tt><big>(</big><em>directory</em>, <em>filename</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.gatherCorePluginInfo" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a <tt class="docutils literal"><span class="pre">PluginInfo</span></tt> as well as the <tt class="docutils literal"><span class="pre">ConfigParser</span></tt> used to build it.</p>
<p>If filename is a valid plugin discovered by any of the known
strategy in use. Returns None,None otherwise.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.getPluginNameAndModuleFromStream">
<tt class="descname">getPluginNameAndModuleFromStream</tt><big>(</big><em>infoFileObject</em>, <em>candidate_infofile=None</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.getPluginNameAndModuleFromStream" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.locatePlugins">
<tt class="descname">locatePlugins</tt><big>(</big><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.locatePlugins" title="Permalink to this definition">¶</a></dt>
<dd><p>Walk through the plugins&#8217; places and look for plugins.</p>
<p>Return the candidates and number of plugins found.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.removeAllAnalyzer">
<tt class="descname">removeAllAnalyzer</tt><big>(</big><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.removeAllAnalyzer" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove all analyzers.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.removeAnalyzers">
<tt class="descname">removeAnalyzers</tt><big>(</big><em>name</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.removeAnalyzers" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes analyzers of a given name.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.setAnalyzers">
<tt class="descname">setAnalyzers</tt><big>(</big><em>analyzers</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.setAnalyzers" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets a new set of analyzers.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">the new analyzers won&#8217;t be aware of the plugin
info class that may have been set via a previous
call to <tt class="docutils literal"><span class="pre">setPluginInfoClass</span></tt>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.setPluginInfoClass">
<tt class="descname">setPluginInfoClass</tt><big>(</big><em>picls</em>, <em>name=None</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.setPluginInfoClass" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the class that holds PluginInfo. The class should inherit
from <tt class="docutils literal"><span class="pre">PluginInfo</span></tt>.</p>
<p>If name is given, then the class will be used only by the corresponding analyzer.</p>
<p>If name is None, the class will be set for all analyzers.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.setPluginInfoExtension">
<tt class="descname">setPluginInfoExtension</tt><big>(</big><em>ext</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.setPluginInfoExtension" title="Permalink to this definition">¶</a></dt>
<dd><p>DEPRECATED(&gt;1.9): for backward compatibility. Directly configure the
IPluginLocator instance instead !</p>
<p>This will only work if the strategy &#8220;info_ext&#8221; is active
for locating plugins.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.setPluginPlaces">
<tt class="descname">setPluginPlaces</tt><big>(</big><em>directories_list</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.setPluginPlaces" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the list of directories where to look for plugin places.</p>
</dd></dl>

<dl class="method">
<dt id="yapsy.PluginFileLocator.PluginFileLocator.updatePluginPlaces">
<tt class="descname">updatePluginPlaces</tt><big>(</big><em>directories_list</em><big>)</big><a class="headerlink" href="#yapsy.PluginFileLocator.PluginFileLocator.updatePluginPlaces" title="Permalink to this definition">¶</a></dt>
<dd><p>Updates the list of directories where to look for plugin places.</p>
</dd></dl>

</dd></dl>

</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/yapsy-big.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">PluginFileLocator</a><ul>
<li><a class="reference internal" href="#role">Role</a><ul>
<li><a class="reference internal" href="#customization">Customization</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="FilteredPluginManager.html"
                        title="previous chapter">FilteredPluginManager</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="IPluginLocator.html"
                        title="next chapter">IPluginLocator</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/PluginFileLocator.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="IPluginLocator.html" title="IPluginLocator"
             >next</a> |</li>
        <li class="right" >
          <a href="FilteredPluginManager.html" title="FilteredPluginManager"
             >previous</a> |</li>
        <li><a href="index.html">Yapsy 1.10.2 documentation</a> &raquo;</li>
          <li><a href="Extensions.html" >Built-in Extensions</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2010-2013, Thibauld Nion.
      Last updated on Oct 05, 2013.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>