diff --git a/pisi/cli/blame.py b/pisi/cli/blame.py new file mode 100644 index 00000000..16383db7 --- /dev/null +++ b/pisi/cli/blame.py @@ -0,0 +1,63 @@ +# -*- coding:utf-8 -*- +# +# Copyright (C) 2009, TUBITAK/UEKAE +# +# 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. +# +# Please read the COPYING file. +# + +import optparse + +import gettext +__trans = gettext.translation('pisi', fallback=True) +_ = __trans.ugettext + +import pisi.cli.command as command +import pisi.context as ctx +import pisi.api +import pisi.db + +class Blame(command.Command): + __doc__ = _("""Info about the package owner + +Usage: blame ... + +""") + + __metaclass__ = command.autocommand + + def __init__(self, args=None): + super(Blame, self).__init__(args) + self.packagedb = pisi.db.packagedb.PackageDB() + + name = ("blame", "bl") + + def options(self): + group = optparse.OptionGroup(self.parser, _("blame options")) + group.add_option("-r", "--release", action="store", type="int", help=_("Blame for the given release")) + self.parser.add_option_group(group) + + def run(self): + self.init(database=False, write=False) + for package in self.args: + if self.packagedb.has_package(package): + pkg = self.packagedb.get_package(package) + release = ctx.get_option('release') + if not release: + self.print_package_info(pkg) + else: + for hno, update in enumerate(pkg.history): + if int(update.release) == release: + self.print_package_info(pkg, hno) + + def print_package_info(self, package, hno=0): + s = _('Name: %s, version: %s, release: %s\n') % ( + package.name, package.history[hno].version, package.history[hno].release) + s += _('Package Maintainer: %s <%s>\n') % (unicode(package.source.packager.name), package.source.packager.email) + s += _('Update Date: %s\n' % package.history[hno].date) + s += _('\n%s\n' % package.history[hno].comment) + print s diff --git a/pisi/cli/pisicli.py b/pisi/cli/pisicli.py index 27baf142..b28d7189 100644 --- a/pisi/cli/pisicli.py +++ b/pisi/cli/pisicli.py @@ -21,6 +21,7 @@ import pisi import pisi.cli import pisi.cli.command as command import pisi.cli.addrepo +import pisi.cli.blame import pisi.cli.build import pisi.cli.check import pisi.cli.clean