-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstore.py
30 lines (28 loc) · 927 Bytes
/
store.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
import os
def create_Folder_website(direction):
if not os.path.exists(direction):
os.mkdir(direction)
def create_data_files(project_name,url):
pathlinks=os.path.join( project_name,"linksofwebsite.txt")
pathcrawled=os.path.join(project_name,"linkscrawled.txt")
if not os.path.isfile(pathlinks):
with open(pathlinks, 'w') as p:
p.write(url)
if not os.path.isfile(pathcrawled):
with open(pathcrawled , 'w') as p:
p.write('')
def add_to_file(direction , data):
with open(direction ,'a') as f:
f.writelines(data)
def delete_data(direction):
open(direction,'w').close()
def file_to_set(direction):
res = []
with open(direction,'r') as f:
for line in f:
res.append(line)
return res
def set_to_file(direction,data):
with open(direction,'w') as f:
for val in data:
f.writelines(val+'\n')