Ejemplo n.º 1
0
#
# 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, see <http://www.gnu.org/licenses/>.

from __future__ import absolute_import, print_function, unicode_literals

__metaclass__ = type
__all__ = ['Cruft']

from janitor.plugincore.i18n import setup_gettext
_ = setup_gettext()

from janitor.plugincore.exceptions import UnimplementedMethod


class Cruft:
    """One piece of cruft to be cleaned out.

    A piece of cruft can be a file, a package, a configuration tweak that is
    missing, or something else.

    This is a base class, which does nothing. Subclasses do the actual work,
    though they must override the `get_shortname()` and `cleanup()` methods.
    """
    def get_prefix(self):
        """Return the unique prefix used to group this type of cruft.
Ejemplo n.º 2
0
__all__ = [
    'DpkgStatusCruft',
    'DpkgStatusPlugin',
]


import logging
import subprocess

from apt_pkg import TagFile

from janitor.plugincore.cruft import Cruft
from janitor.plugincore.i18n import setup_gettext
from janitor.plugincore.plugin import Plugin

_ = setup_gettext()


class DpkgStatusCruft(Cruft):
    def __init__(self, n_items):
        self.n_items = n_items

    def get_prefix(self):
        return 'dpkg-status'

    def get_prefix_description(self):
        return _('%i obsolete entries in the status file') % self.n_items

    def get_shortname(self):
        return _('Obsolete entries in dpkg status')