File: secret.py

package info (click to toggle)
python-inquirerpy 0.3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,088 kB
  • sloc: python: 9,463; makefile: 15
file content (33 lines) | stat: -rw-r--r-- 1,028 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
28
29
30
31
32
33
from InquirerPy import prompt
from InquirerPy.validator import PasswordValidator

original_password = "InquirerPy45@"


def main():
    questions = [
        {
            "type": "password",
            "message": "Old password:",
            "transformer": lambda _: "[hidden]",
            "validate": lambda text: text == original_password,
            "invalid_message": "Wrong password",
            "long_instruction": "Original password: InquirerPy45@",
        },
        {
            "type": "password",
            "message": "New password:",
            "name": "new_password",
            "validate": PasswordValidator(
                length=8, cap=True, special=True, number=True
            ),
            "transformer": lambda _: "[hidden]",
            "long_instruction": "Password require length of 8, 1 cap char, 1 special char and 1 number char.",
        },
        {"type": "confirm", "message": "Confirm?", "default": True},
    ]
    result = prompt(questions)


if __name__ == "__main__":
    main()