doapfiend.plugins

Package doapfiend :: Package plugins |
[hide private]
[frames] | no frames]

# Package plugins

source code

# Writing Plugins

doapfiend supports setuptools_ entry point plugins.

There are two basic rules for plugins:

- Plugin classes should subclass `doapfiend.plugins.Plugin`_.
- Plugins may implement any of the methods described in the class PluginInterface in doapfiend.plugins.base. Please note that this class is for documentary purposes only; plugins may not subclass PluginInterface.

Setuptools: http://peak.telecommunity.com/DevCenter/setuptools Doapfiend Plugins: http://trac.doapspace.org/doapfiend/wiki/DoapfiendPlugins

## Registering

For doapfiend to find a plugin, it must be part of a package that uses setuptools, and the plugin must be included in the entry points defined in the setup.py for the package:

     setup(name='Some plugin',
           ...
           entry_points = {
               'doapfiend.plugins': [
                   'someplugin = someplugin:SomePlugin'
                   ]
               },
           ...
           )

Once the package is installed with install or develop, doapfiend will be able to load the plugin.

## Defining options

All plugins must implement the methods ``add_options(self, parser, env)`` and ``configure(self, options, conf)``. Subclasses of doapfiend.plugins.Plugin that want the standard options should call the superclass methods.

doapfiend uses optparse.OptionParser from the standard library to parse arguments. A plugin's ``add_options()`` method receives a parser instance. It's good form for a plugin to use that instance only to add additional arguments that take only long arguments (--like-this). Most of doapfiend's built-in arguments get their default value from an environment variable. This is a good practice because it allows options to be utilized when run through some other means than the doapfiendtests script.

A plugin's ``configure()`` method receives the parsed ``OptionParser`` options object, as well as the current config object. Plugins should configure their behavior based on the user-selected settings, and may raise exceptions if the configured behavior is nonsensical.

## Logging

doapfiend uses the logging classes from the standard library. To enable users to view debug messages easily, plugins should use ``logging.getLogger()`` to acquire a logger in the ``doapfiend.plugins`` namespace.

Submodules | [hide private]
doapfiend.plugins.base: All plugins should inherit doapfiend.plugins.Plugin doapfiend.plugins.fields: This plugin outputs DOAP in human-readable plain text doapfiend.plugins.freshmeat: Currently this plugin uses http://doapspace.org/ to fetch DOAP for Freshmeat doapfiend.plugins.homepage: Fetches DOAP by searching doapspace.org by a project's homepage. doapfiend.plugins.n3: This is a plugin for formatting DOAP output as N3 (Notation 3) syntax. doapfiend.plugins.ohloh: This plugin uses http://rdfohloh.wikier.org/ to fetch DOAP for projects listed on Ohlohh. doapfiend.plugins.pkg_index: Plugin helper to fetch a single DOAP file from doapspace.org by Package Index doapfiend.plugins.pypi: Currently this plugin uses http://doapspace.org/ to fetch DOAP for PyPI (The Python Package Index) doapfiend.plugins.sourceforge: Currently this plugin uses http://doapspace.org/ to fetch DOAP for SourceForge doapfiend.plugins.text: This plugin outputs DOAP in human-readable plain text doapfiend.plugins.url: This plugin loads DOAP by its URL or path to a filename. doapfiend.plugins.xml: This plugin outputs DOAP in RDF/XML It basically does nothing because all DOAP today is in RDF/XML.

Functions | [hide private]
call_plugins(plugins, method, *arg, **kw) Call all method on plugins in list, that define it, with provided arguments. | source code
load_plugins(builtin=True, others=True) Load plugins, either builtin, others, or both. | source code

Variables | [hide private]
| LOG = `logging.getLogger('doapfiend')`
| builtin_plugins = ``[``'``url``'``,` `'``homepage``'``,` `'``n3``'``,` `'``xml``'``,` `'``text``'``,` `'``so``...``

Function Details | [hide private]

### call_plugins(plugins, method, *arg, **kw) | source code
Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned.

Variables Details | [hide private]

  ### builtin_plugins Value:
      ['url',
       'homepage',
       'n3',
       'xml',
       'text',
       'sourceforge',
       'pypi',
       'freshmeat',
      ...