-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson6_1.py
More file actions
37 lines (30 loc) · 1.26 KB
/
Copy pathlesson6_1.py
File metadata and controls
37 lines (30 loc) · 1.26 KB
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
34
35
36
37
# ...
import argparse
import os
ans = "Working...\n--------------------------------------\n"
print(ans)
parser = argparse.ArgumentParser()
parser.add_argument('-n', '--name', default='Anonimous', help="Имя пользователя")
parser.add_argument('-p', '--path', default='', help="Путь к файлу изображения")
parser.add_argument('-noQ', '--noQuest', action='store_true', help="Подавление вопросов пользователю")
args = parser.parse_args()
# print(f'Hi, {args.name}!')
print(f'Привет, {args.name}!')
# print(f'Текущие параметры: {str(vars(args))[1:-1]}', end='\n\n')
print(f'Проверяю путь к изображению: {args.path}...')
if os.path.exists(args.path):
succes = f'Файл {os.path.basename(args.path)} успешно удалён!'
if args.noQuest:
os.remove(args.path)
print(succes)
else:
ans = input(f'Удалить файл {os.path.basename(args.path)}? Y/N: ').capitalize()
if ans[0] == 'Y':
os.remove(args.path)
print(succes)
else:
pass
else:
print(f'Путь {args.path} не существует.')
ans = "\n--------------------------------------\n...End of work"
print(ans)