-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfileutil.py
More file actions
73 lines (68 loc) · 2.11 KB
/
Copy pathfileutil.py
File metadata and controls
73 lines (68 loc) · 2.11 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
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
64
65
66
67
68
69
70
71
72
73
import shutil
class FileUtil:
def __init__(self):
pass
def readLine(self, index):
print(index)
if index == False:
try:
shutil.copy("temp.jpg", "static/media/temp.jpg")
except:
pass
return "False"
else:
peopleFile = open("med_info.txt", "r")
people = []
for line in peopleFile:
people.append(line)
try:
returnStatement = people[int(index)]
shutil.copy(f"{returnStatement.split(',')[0]}.jpg", "static/media/temp.jpg")
except:
peopleFile.close()
try:
shutil.copy("temp.jpg", "static/media/temp.jpg")
except:
pass
return "False"
peopleFile.close()
print(returnStatement)
return returnStatement
def updateLine(self, newLine):
peopleFile = open("med_info.txt", "r")
people = []
for line in peopleFile:
people.append(line)
peopleFile.close()
f = open("temp.txt", 'r')
index = f.read()
f.close()
print(people)
people[people.index(index)] = newLine + "\n"
f = open("temp.txt", "w")
f.write(newLine + "\n")
f.close()
peopleFile = open("med_info.txt", "w")
for item in people:
peopleFile.write(item)
peopleFile.close()
def newLine(self, newLine):
peopleFile = open("med_info.txt", "r")
people = []
for line in peopleFile:
people.append(line)
peopleFile.close()
people.append(newLine + "\n")
f = open("temp.txt", "w")
f.write(newLine + "\n")
f.close()
peopleFile = open("med_info.txt", "w")
for item in people:
peopleFile.write(item)
peopleFile.close()
def saveImage(self, newLine):
identifier = newLine.split(',')[0]
try:
shutil.copy("static/media/temp.jpg", f"{identifier}.jpg")
except:
pass