File: filepath.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 (31 lines) | stat: -rw-r--r-- 800 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
import os

from InquirerPy import prompt
from InquirerPy.validator import PathValidator


def main():
    home_path = "~/" if os.name == "posix" else "C:\\"
    questions = [
        {
            "type": "filepath",
            "message": "Enter file to upload:",
            "name": "location",
            "default": home_path,
            "validate": PathValidator(is_file=True, message="Input is not a file"),
            "only_files": True,
        },
        {
            "type": "filepath",
            "message": "Enter path to download:",
            "validate": PathValidator(is_dir=True, message="Input is not a directory"),
            "name": "destination",
            "only_directories": True,
        },
    ]

    result = prompt(questions)


if __name__ == "__main__":
    main()