-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_base_processor.py
More file actions
32 lines (24 loc) · 1.2 KB
/
data_base_processor.py
File metadata and controls
32 lines (24 loc) · 1.2 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
from mylang import *
from startup import *
def find_last_temp_name(project_object : dict) -> str:
existing_files = sorted(list(map(lambda f: int(f[:-len(".json")]), os.listdir(project_object["stat_dir"]))))
last_file_index = existing_files[-1]
last_file_name = str(last_file_index) + ".json"
last_file_content = json.loads(open(os.path.join(project_object["stat_dir"], last_file_name), "r").read())
last_file_length = len(last_file_content)
this_storage_name = last_file_name
if last_file_length > stat_file_capacity:
this_storage_name = str(last_file_index + 1) + ".json"
return this_storage_name
def find_last_temp_path(project_object : dict) -> str:
return os.path.join(project_object["stat_dir"], find_last_temp_name(project_object))
def load_last_proj_temp(proj_obj : dict) -> Dict:
all_pr_data = json.loads(open(find_last_temp_path(proj_obj), "r").read())
return all_pr_data[-1]
def select_project_by_name(all_projects : List[dict], project_name : str) -> Optional[dict]:
for pr in all_projects:
if pr["name"] == project_name:
return pr
return None
if __name__ == '__main__':
print_as_json(load_last_proj_temp(project_data[0]))