File: //lib/python3/dist-packages/janitor/plugincore/__pycache__/cruft.cpython-310.pyc
o
z��c � @ sN d dl mZmZmZ eZdgZd dlmZ e� Z d dl
mZ G dd� d�ZdS )� )�absolute_import�print_function�unicode_literals�Cruft)�
setup_gettext)�UnimplementedMethodc @ s� e Zd ZdZdd� Zedd� �Zdd� Zedd � �Zd
d� Z edd
� �Z
dd� Zedd� �Zdd� Z
dd� Zedd� �Zdd� Zedd� �Zdd� ZdS )r a3 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.
c C s | j jS )a� Return the unique prefix used to group this type of cruft.
For example, the .deb package called 'foo' would have a prefix
of 'deb'. This way, the package foo is not confused with the
file foo, or the username foo.
Subclasses SHOULD define this. The default implementation
returns the name of the class, which is rarely useful to
the user.
)� __class__�__name__��self� r �:/usr/lib/python3/dist-packages/janitor/plugincore/cruft.py�
get_prefix( s zCruft.get_prefixc C � | � � S �N)r r
r r r
�prefix5 � zCruft.prefixc C r )z4Return human-readable description of class of cruft.��get_descriptionr
r r r
�get_prefix_description9 r zCruft.get_prefix_descriptionc C r r )r r
r r r
�prefix_description= r zCruft.prefix_descriptionc C �
t | j��)a� Return the name of this piece of cruft.
The name should be something that the user will understand. For
example, it might be the name of a package, or the full path to a
file.
The name should be unique within the unique prefix returned by
`get_prefix()`. The prefix MUST NOT be included by this method, the
`get_name()` method does that instead. The intent is that
`get_shortname()` will be used by the user interface in contexts where
the prefix is shown separately from the short name, and `get_name()`
when a single string is used.
Subclasses MUST define this. The default implementation raises an
exception.
)r �
get_shortnamer
r r r
r A s
zCruft.get_shortnamec C r r )r r
r r r
� shortnameT r zCruft.shortnamec C s d� | j| j�S )aJ Return prefix plus name.
See `get_prefix()` and `get_shortname()` for a discussion of the
prefix and the short name. This method will return the prefix, a
colon, and the short name.
The long name will used to store state/configuration data: _this_
package should not be removed.
z{}:{})�formatr r r
r r r
�get_nameX s
zCruft.get_namec C r r )r r
r r r
�named r z
Cruft.namec C s d� | jj| j�S )Nz <{} "{}">)r r r r r
r r r
�__repr__h s zCruft.__repr__c C � dS )a� Return a description of this piece of cruft.
This may be arbitrarily long. The user interface will take care of
breaking it into lines or otherwise presenting it to the user in a
nice manner. The description should be plain text UTF-8 unicode.
The default implementation returns the empty string. Subclasses MAY
override this as they wish.
� r r
r r r
r k s
zCruft.get_descriptionc C r r r r
r r r
�descriptionw r zCruft.descriptionc C r )a` Return amount of disk space reserved by this piece of cruft.
The unit is bytes.
The disk space in question should be the amount that will be freed if
the cruft is cleaned up. The amount may be an estimate (i.e. a
guess). It is intended to be shown to the user to help them decide
what to remove and what to keep.
This will also be used by the user interface to better estimate how
much remaining time there is when cleaning up a lot of cruft.
For some types of cruft, this is not applicable and they should return
`None`. The base class implementation does that, so subclasses MUST
define this method if it is useful for them to return something else.
The user interface will distinguish between None (not applicable) and
0 (no disk space being used).
Nr r
r r r
�get_disk_usage{ s zCruft.get_disk_usagec C r r )r! r
r r r
�
disk_usage� r zCruft.disk_usagec C r )a Clean up this piece of cruft.
Depending on the type of cruft, this may mean removing files,
packages, modifying configuration files, or something else.
The default implementation raises an exception. Subclasses MUST
override this.
)r �cleanupr
r r r
r# � s
z
Cruft.cleanupN)r �
__module__�__qualname__�__doc__r �propertyr r r r r r r r r r r! r"