plugins/__init__.py
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Mon, 23 Jun 2008 13:42:22 +0200
changeset 6 6aad8b499e86
parent 0 7710b138d4eb
permissions -rw-r--r--
fix reST markup

# Copyright (c) 2004 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
"""
oobrother plugins
"""

__revision__ = '$Id: __init__.py,v 1.7 2006-04-23 13:53:52 nico Exp $'

from oobrother.config_tools import PluggableConfig

class AbstractPlugIn:
    """the docstring of a plugin is used to explain it in the gui"""

    # the short name of the plugin
    name = ''
    # mime types handled by this module. See the Registry.register
    # documentation
    mimetypes = ()
    # list of options. See logilab.common.configuration.
    options = ()
    
    def __init__(self, config_file=None):
        self.appl = None # set on registration
        self.cfg = None
        if self.options:
            self.cfg = PluggableConfig(self.name, config_file, self.options)

    def set_application(self, appl):
        """set the application (on registration)"""
        assert self.appl is None
        self.appl = appl
        
    def support_directory(self, thedir):
        """return true if this plugin may have some actions for the
        given directory
        """
        return False
    
    def get_actions(self, thefile):
        """return a list of 2-uple (action label, callback method)"""
        raise NotImplementedError()

    def subconfiguration(self):
        """return subconfiguration objects if any"""
        return []

    def execute_in_console(self, cmd):
        """run the command in the shared console"""
        self.appl.console.execute(cmd)