Projekt

Obecné

Profil

Stáhnout (2.52 KB) Statistiky
| Větev: | Revize:
1 d6ca840d petrh
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 753d424e petrh
def hard_reset_dataset(dataset_name):
17 d6ca840d petrh
    """
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 753d424e petrh
def soft_reset_dataset(dataset_name):
33
    """
34
    Resets all saved data in dataset except config and implementation
35
    Args:
36
        dataset_name: name of dataset that has existing configuration file
37
    """
38
    path = PROCESSED_DATA_PATH + dataset_name + "/"
39
    folder_processor.clean_folder(path)
40
41
    database_loader.remove_dataset_database(dataset_name)
42
43
44
45
def soft_reset_all_datasets():
46 d6ca840d petrh
    """
47
    Resets all saved data in all datasets with config file except configs and implementation
48
    """
49
    datasets = os.listdir(CONFIG_FILES_PATH)
50
51
    for dataset in datasets:
52 753d424e petrh
        soft_reset_dataset(dataset.split('.')[0])
53 d6ca840d petrh
54
55 753d424e petrh
def hard_reset_all_datasets():
56
    """
57
    Resets all saved data in all datasets with config file except configs and implementation
58
    """
59
    datasets = os.listdir(CONFIG_FILES_PATH)
60
61
    for dataset in datasets:
62
        hard_reset_dataset(dataset.split('.')[0])
63
64 d6ca840d petrh
65
print("Zadejte jméno Datasetu který chcete resetovat (pokud všechny zadejte '-ALL'):\n")
66
67
dataset_name = input().upper()
68
69 753d424e petrh
print("Chcete smazat i stažené stažená data ? (ANO/NE) \n")
70
71 528cc257 petrh
input_decision = input().upper()
72 753d424e petrh
73 d6ca840d petrh
if dataset_name == '-ALL':
74 528cc257 petrh
    if input_decision == 'ANO':
75 753d424e petrh
        hard_reset_all_datasets()
76 528cc257 petrh
    elif input_decision == 'NE':
77 753d424e petrh
        soft_reset_all_datasets()
78
    else:
79
        print('Neplatný vstup (ANO/NE)')
80 d6ca840d petrh
else:
81
    test = configure_functions.check_if_there_is_a_config_file(dataset_name)
82
    if test == True:
83 528cc257 petrh
        if input_decision == 'ANO':
84 753d424e petrh
            hard_reset_dataset(dataset_name)
85 528cc257 petrh
        elif input_decision == 'NE':
86 753d424e petrh
            soft_reset_dataset(dataset_name)
87
        else:
88
            print('Neplatný vstup (ANO/NE)')
89 d6ca840d petrh
    else:
90
        print("Tento dataset v architektuře neexistuje")