File: user.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-- 776 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 trashcli.lib.my_input import Input
from trashcli.put.describer import Describer


class User:
    def __init__(self,
                 my_input,  # type: Input
                 describer,  # type: Describer
                 ):
        self.input = my_input
        self.describer = describer


    def ask_user_about_deleting_file(self, program_name, path):
        reply = self.input.read_input(
            "%s: trash %s '%s'? " % (program_name,
                                     self.describer.describe(path), path))
        return parse_user_reply(reply)


user_replied_no = "user_replied_no"
user_replied_yes = "user_replied_yes"


def parse_user_reply(reply):
    return {False: user_replied_no,
            True: user_replied_yes}[reply.lower().startswith("y")]