-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (27 loc) · 1.08 KB
/
main.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
"""This is a main file to start the parser"""
from datetime import datetime
from time import sleep
from constants import (
RESULT_PATH, TIME_DELAY_24_H, TABLE_NAME, PARSE_TAGS_SHEET, PROJECT_FOLDERS,
)
from container import table_manager, storage_manager
from utils import load_from_json, create_folders
# ------------------------------------------------------------------------
def main() -> None:
"""Main function with necessary logic"""
create_folders(PROJECT_FOLDERS)
while True:
start_time = datetime.now()
table_manager.open_table(TABLE_NAME)
parse_data = table_manager.load_from_table(PARSE_TAGS_SHEET)
if not parse_data:
parse_data = storage_manager.load_from_storage()
if parse_data:
old_data = load_from_json(RESULT_PATH)
table_manager.refresh(parse_data, old_data)
storage_manager.save_to_storage(parse_data)
table_manager.close_table()
work_time = (datetime.now() - start_time).seconds
sleep(TIME_DELAY_24_H - work_time)
if __name__ == '__main__':
main()