|
Packit Service |
27f74b |
# -*- coding: utf-8 -*-
|
|
Packit Service |
27f74b |
#
|
|
Packit Service |
27f74b |
# Show newly installed leaf packages and packages that became leaves
|
|
Packit Service |
27f74b |
# after a transaction.
|
|
Packit Service |
27f74b |
#
|
|
Packit Service |
27f74b |
# Copyright © 2009-2015 Ville Skyttä
|
|
Packit Service |
27f74b |
#
|
|
Packit Service |
27f74b |
# This copyrighted material is made available to anyone wishing to use,
|
|
Packit Service |
27f74b |
# modify, copy, or redistribute it subject to the terms and conditions of
|
|
Packit Service |
27f74b |
# the GNU General Public License v.2, or (at your option) any later version.
|
|
Packit Service |
27f74b |
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
Packit Service |
27f74b |
# ANY WARRANTY expressed or implied, including the implied warranties of
|
|
Packit Service |
27f74b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|
Packit Service |
27f74b |
# Public License for more details. You should have received a copy of the
|
|
Packit Service |
27f74b |
# GNU General Public License along with this program; if not, write to the
|
|
Packit Service |
27f74b |
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
27f74b |
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
|
|
Packit Service |
27f74b |
# source code or documentation are not subject to the GNU General Public
|
|
Packit Service |
27f74b |
# License and may only be used or replicated with the express permission of
|
|
Packit Service |
27f74b |
# Red Hat, Inc.
|
|
Packit Service |
27f74b |
#
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
import dnf
|
|
Packit Service |
27f74b |
from dnfpluginscore import _
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
class ShowLeaves(dnf.Plugin):
|
|
Packit Service |
27f74b |
name = "show-leaves"
|
|
Packit Service |
27f74b |
leaves_command = None
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def __init__(self, base, cli):
|
|
Packit Service |
27f74b |
super(ShowLeaves, self).__init__(base, cli)
|
|
Packit Service |
27f74b |
self.base = base
|
|
Packit Service |
27f74b |
self.cli = cli
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def resolved(self):
|
|
Packit Service |
27f74b |
tx = self.base.transaction
|
|
Packit Service |
27f74b |
if not tx.install_set and not tx.remove_set:
|
|
Packit Service |
27f74b |
return
|
|
Packit Service |
27f74b |
leaves_command = self.cli.cli_commands.get("leaves")
|
|
Packit Service |
27f74b |
if not leaves_command:
|
|
Packit Service |
27f74b |
return
|
|
Packit Service |
27f74b |
self.leaves_command = leaves_command(self.cli)
|
|
Packit Service |
27f74b |
self.pre_leaves = set(("%s.%s" % (x.name, x.arch)
|
|
Packit Service |
27f74b |
for x in self.leaves_command.findleaves()))
|
|
Packit Service |
27f74b |
|
|
Packit Service |
27f74b |
def transaction(self):
|
|
Packit Service |
27f74b |
if not self.leaves_command:
|
|
Packit Service |
27f74b |
return
|
|
Packit Service |
27f74b |
self.post_leaves = set(("%s.%s" % (x.name, x.arch)
|
|
Packit Service |
27f74b |
for x in self.leaves_command.findleaves()))
|
|
Packit Service |
27f74b |
new_leaves = self.post_leaves - self.pre_leaves
|
|
Packit Service |
27f74b |
if new_leaves:
|
|
Packit Service |
27f74b |
print(_("New leaves:"))
|
|
Packit Service |
27f74b |
for leaf in sorted(new_leaves):
|
|
Packit Service |
27f74b |
print(" {}".format(leaf))
|