blob: b2691778957420e11d03fc79e5c54842ec297e4b (
plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
from ftplib import parse150
import os, sys
def txthandler(path, filename):
f = open(path, "r")
contents = f.read()
filename.write('<!DOCTYPE html>'
'<html lang ="en">'
'<head>'
'<title>'+contents[0:contents.rfind('\n')]+'</title>'
'<link rel="stylesheet" type="text/css" href="stylesheet.css">'
'<link rel="icon" type="image/x-icon" href="images/favicon.ico">'
'<meta charset="utf-8"/>'
'</head>'
'</html>')
print(f.read())
return 0
def pdfhandler(path):
f = open(path)
print(f.read())
return 0
def dochandler(path):
f = open(path)
print(f.read())
return 0
#Attempting to pass txt file in path
path = 'C:/Users/a big fuck/Documents/beansandtoast.txt'
extension = path[path.rfind('.')+1: len(path)]
filename = path[path.rfind('/')+1: path.rfind('.')]
if os.path.exists(filename+".html") == True:
os.remove(filename+".html")
htmlfile = open(filename+".html", "x")
if extension =='txt':
txthandler(path, htmlfile)
elif extension == 'pdf':
pdfhandler(path)
elif extension == 'doc' or 'docx':
dochandler(path)
else:
print("Extension not recognized")
sys.exit()
|