author root
Wed, 26 Apr 2006 10:48:09 +0000
changeset 0 7710b138d4eb
permissions -rw-r--r--
forget the past. forget the past.

# Copyright (c) 2004 LOGILAB S.A. (Paris, FRANCE).
# --
# 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.
"""Basic plugin for some debian files

__revision__ = '$Id:,v 1.3 2004-10-14 16:31:06 arthur Exp $'

import commands

import gobject

from oobrother.plugins import AbstractPlugIn
from import ConfigurableListWindow

class DebianPlugin(AbstractPlugIn):
    """a plugin for text file, propo"""
    name = 'debian'
    mimetypes = ('application/x-debian-package',
    def __init__(self):
        AbstractPlugIn.__init__(self, config_file='debian.ini')
        self.lintian_window = LintianReportWindow()
    def get_actions(self, thefile):
        """return actions provided by this plugin for the give file"""
        actions = []
        if thefile.basename.endswith('.changes'):
            actions.append( ('show content', self.cb_debc) )
            actions.append( ('lintian', self.cb_lintian) )
        return [('debian', actions)]

    def cb_lintian(self, menuitem, thefile):
        """execute lintian"""
    def cb_debc(self, menuitem, thefile):
        """execute debc"""
        self.execute_in_console('debc %s' % thefile.abspath)        

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

class LintianReportWindow(ConfigurableListWindow):
    """display lintian report in a 3 columns list (configurable)"""
    name = 'lintian'
    options = (
        ('all-checks', {'type': 'yn', 'default': True}),
        ('checks', {'type': 'csv', 'default': ()}),
    def __init__(self):
        ConfigurableListWindow.__init__(self, 'lintian.ini',
                                        (gobject.TYPE_STRING, # type
                                         gobject.TYPE_STRING, # path
                                         gobject.TYPE_STRING, # message
                                        ('Type', 'Package', 'Message'),
        self.init_columns(self.cfg['columns'], (0, 0, 0))
    def lintian(self, thefile):
        """check the given wrapped package using checkpackage in a safe
        cmd = 'lintian'
        if not self.cfg['all-checks']:
            cmd = 'lintian %s' % ','.join(self.cfg['checks'])
        self.set_title('lintian: %s' % thefile.abspath)
        output = commands.getoutput("%s %s" % (cmd, thefile.abspath))
        for line in output.splitlines():
            self.append_line( line.split(':', 2) )

def register(registry):
    """register plugins from this module to the plugins registry"""