1
# Copyright (C) 2008-2012 Canonical, Ltd.
3
# This program is free software: you can redistribute it and/or modify it
4
# under the terms of the GNU General Public License as published by the Free
5
# Software Foundation, version 3 of the License.
7
# This program is distributed in the hope that it will be useful, but WITHOUT
8
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
# You should have received a copy of the GNU General Public License along with
13
# this program. If not, see <http://www.gnu.org/licenses/>.
15
from __future__ import absolute_import, print_function, unicode_literals
23
from janitor.plugincore.cruft import Cruft
24
from janitor.plugincore.i18n import setup_gettext
28
class PackageCruft(Cruft):
29
"""Cruft that is .deb packages.
31
This type of cruft consists of .deb packages installed onto the system
32
which can be removed. Various plugins may decide that various packages
33
are cruft; they can all use objects of PackageCruft type to mark such
34
packages, regardless of the reason the packages are considered cruft.
36
When PackageCruft instantiated, the package is identified by an
37
apt.Package object. That object is used for all the real operations, so
38
this class is merely a thin wrapper around it.
41
def __init__(self, pkg, description):
43
self._description = description
48
def get_prefix_description(self):
49
return _('.deb package')
51
def get_shortname(self):
54
def get_description(self):
55
return '{}\n\n{}'.format(self._description, self._pkg.summary)
57
def get_disk_usage(self):
58
return self._pkg.installedSize
61
self._pkg.markDelete()