-
Notifications
You must be signed in to change notification settings - Fork 0
/
restore.py
29 lines (22 loc) · 722 Bytes
/
restore.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
28
29
import tools
def restore():
tools.empty_folder('restored_file')
chapters = 0
meta_data = open('raw_data/meta_data.txt', 'r')
meta_info = []
for row in meta_data:
temp = row.split('\n')
temp = temp[0]
temp = temp.split('=')
meta_info.append(temp[1])
address = 'restored_file/' + meta_info[0]
list_of_files = sorted(tools.list_dir('files'))
with open(address, 'wb') as writer:
for file in list_of_files:
path = 'files/' + file
with open(path, 'rb') as reader:
for line in reader:
writer.write(line)
reader.close()
writer.close()
tools.empty_folder('files')