-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.py
27 lines (21 loc) · 849 Bytes
/
file.py
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
import os, readline, path_complete
from email import encoders
from email.mime.base import MIMEBase
name = path_complete.Completer()
readline.set_completer(name.path_completer)
class File():
def __init__(self):
pass
def annex(self):
file_path = str(input("File PATH: "))
while os.path.isfile(file_path) == False:
if os.path.isdir(file_path) == True:
print('Oops... You can not add a folder')
else:
print('Oops... File not found')
file_path = str(input("File PATH: "))
part = MIMEBase('application', 'octet-stream')
part.set_payload((open(file_path, 'rb')).read())
encoders.encode_base64(part)
part.add_header('Content-Disposition', 'attachment; filename= %s' % (os.path.basename(file_path)))
return part