-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObserver.pyw
More file actions
69 lines (54 loc) · 1.95 KB
/
Observer.pyw
File metadata and controls
69 lines (54 loc) · 1.95 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
from startup import *
from file_walker import *
from datetime import datetime
import data_base_processor
def get_project_data(project_object : dict):
# Find proper file for writing data
this_storage_path = data_base_processor.find_last_temp_path(project_object)
if not os.path.exists(this_storage_path):
temp_file2 = open(this_storage_path, "w")
temp_file2.write("[\n\t\n]")
temp_file2.close()
this_storage_data = json.loads(open(this_storage_path, "r").read())
# Calculate current time:
now = datetime.now()
# Main content:
scraped = scrape_all_dirs(project_object["directories"], project_object["extensions"])
print_good_info(f"{project_object['name']} : Scraped!")
to_store = {
"time": str(now),
"data": scraped
}
this_storage_data.append(to_store)
return this_storage_data
def process_project(project_object : dict):
# Find proper file for writing data
this_storage_path = data_base_processor.find_last_temp_path(project_object)
# if not os.path.exists(this_storage_path):
# temp_file2 = open(this_storage_path, "w")
# temp_file2.write("[\n\t\n]")
# temp_file2.close()
# this_storage_data = json.loads(open(this_storage_path, "r").read())
#
# # Calculate current time:
# now = datetime.now()
#
#
# # Main content:
#
# scraped = scrape_all_dirs(project_object["directories"], project_object["extensions"])
# print_good_info("Scraped:")
# to_store = {
# "time" : str(now),
# "data" : scraped
# }
# this_storage_data.append(to_store)
# print_as_json(to_store)
this_storage_data = get_project_data(project_object)
out_file = open(this_storage_path, "w")
out_file.write(json.dumps(this_storage_data, indent=4, ensure_ascii=False))
out_file.close()
def process_all_projects():
for project in project_data:
process_project(project)
process_all_projects()