-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutils.py
43 lines (30 loc) · 936 Bytes
/
utils.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""
Contains utility function to update upto which the problems has been downloaded, writing chapter info to a file, resetting configuration,
reading upto which the problems has been downloaded
"""
import pickle
def update_tracker(file_name, problem_num):
"""
"""
with open(file_name, "w") as f:
f.write(str(problem_num))
def dump_chapters_to_file(chapters):
"""
"""
with open('chapters.pickle', 'wb') as f:
pickle.dump(chapters, f)
def reset_configuration():
"""
Resets problem num downloaded upto to -1
Resets all the chapters
Resets html file
"""
update_tracker("track.conf", -1)
dump_chapters_to_file([])
with open("out.html", "wb") as f:
f.write(b" ")
def read_tracker(file_name):
"""
"""
with open(file_name, "r") as f:
return int(f.readline())