1
# Copyright (C) 2008-2012 Canonical, Ltd.
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, version 3 of the License.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
from janitor.plugincore.cruft import Cruft
19
from janitor.plugincore.i18n import setup_gettext
23
class FileCruft(Cruft):
24
"""Cruft that is individual files.
26
This type of cruft consists of individual files that should be removed.
27
Various plugins may decide that various files are cruft; they can all use
28
objects of FileCruft type to mark such files, regardless of the reason the
29
files are considered cruft.
32
def __init__(self, pathname, description):
33
self.pathname = pathname
34
self._disk_usage = os.stat(pathname).st_blocks * 512
35
self._description = description
40
def get_prefix_description(self):
41
return _('A file on disk')
43
def get_shortname(self):
46
def get_description(self):
47
return '{}\n'.format(self._description)
49
def get_disk_usage(self):
50
return self._disk_usage
53
os.remove(self.pathname)