1
|
import os
|
2
|
from Utilities import folder_processor
|
3
|
from Utilities.Database import database_loader
|
4
|
from Utilities import configure_functions
|
5
|
|
6
|
# Path to crawled data
|
7
|
CRAWLED_DATA_PATH = "CrawledData/"
|
8
|
# Path to processed data
|
9
|
PROCESSED_DATA_PATH = "ProcessedData/"
|
10
|
# Path to crawler logs
|
11
|
CRAWLER_LOGS_PATH = "CrawlerLogs/"
|
12
|
# Path to dataset configuration files
|
13
|
CONFIG_FILES_PATH = "DatasetConfigs"
|
14
|
|
15
|
|
16
|
def reset_dataset(dataset_name):
|
17
|
"""
|
18
|
Resets all saved data in dataset except config and implementation
|
19
|
Args:
|
20
|
dataset_name: name of dataset that has existing configuration file
|
21
|
"""
|
22
|
|
23
|
path = CRAWLED_DATA_PATH + dataset_name + "/"
|
24
|
folder_processor.clean_folder(path)
|
25
|
|
26
|
path = PROCESSED_DATA_PATH + dataset_name + "/"
|
27
|
folder_processor.clean_folder(path)
|
28
|
|
29
|
database_loader.remove_dataset_database(dataset_name)
|
30
|
|
31
|
|
32
|
def reset_all_datasets():
|
33
|
"""
|
34
|
Resets all saved data in all datasets with config file except configs and implementation
|
35
|
"""
|
36
|
datasets = os.listdir(CONFIG_FILES_PATH)
|
37
|
|
38
|
for dataset in datasets:
|
39
|
reset_dataset(dataset.split('.')[0])
|
40
|
|
41
|
|
42
|
|
43
|
print("Zadejte jméno Datasetu který chcete resetovat (pokud všechny zadejte '-ALL'):\n")
|
44
|
|
45
|
dataset_name = input().upper()
|
46
|
|
47
|
if dataset_name == '-ALL':
|
48
|
reset_all_datasets()
|
49
|
else:
|
50
|
test = configure_functions.check_if_there_is_a_config_file(dataset_name)
|
51
|
if test == True:
|
52
|
reset_dataset(dataset_name)
|
53
|
else:
|
54
|
print("Tento dataset v architektuře neexistuje")
|