File: failure_reason.py

package info (click to toggle)
trash-cli 0.24.5.26-0.3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,972 kB
  • sloc: python: 9,789; sh: 121; makefile: 11
file content (27 lines) | stat: -rw-r--r-- 715 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from abc import abstractmethod
from typing import NamedTuple

from trashcli.compat import Protocol
from trashcli.lib.environ import Environ
from trashcli.put.core.candidate import Candidate


class LogContext(NamedTuple('LogContext', [
    ('trashee_path', str),
    ('candidate', Candidate),
    ('environ', Environ),
])):
    def shrunk_candidate_path(self):
        return self.candidate.shrink_user(self.environ)

    def trash_dir_norm_path(self):
        return self.candidate.norm_path()

    def files_dir(self):
        return self.candidate.files_dir()


class FailureReason(Protocol):
    @abstractmethod
    def log_entries(self, context):  # type: (LogContext) -> str
        raise NotImplementedError