Revize 753d424e
Přidáno uživatelem Petr Hlaváč před asi 4 roky(ů)
modules/crawler/reset_datasets.py | ||
---|---|---|
13 | 13 |
CONFIG_FILES_PATH = "DatasetConfigs" |
14 | 14 |
|
15 | 15 |
|
16 |
def reset_dataset(dataset_name): |
|
16 |
def hard_reset_dataset(dataset_name):
|
|
17 | 17 |
""" |
18 | 18 |
Resets all saved data in dataset except config and implementation |
19 | 19 |
Args: |
... | ... | |
29 | 29 |
database_loader.remove_dataset_database(dataset_name) |
30 | 30 |
|
31 | 31 |
|
32 |
def reset_all_datasets(): |
|
32 |
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(): |
|
33 | 46 |
""" |
34 | 47 |
Resets all saved data in all datasets with config file except configs and implementation |
35 | 48 |
""" |
36 | 49 |
datasets = os.listdir(CONFIG_FILES_PATH) |
37 | 50 |
|
38 | 51 |
for dataset in datasets: |
39 |
reset_dataset(dataset.split('.')[0]) |
|
52 |
soft_reset_dataset(dataset.split('.')[0])
|
|
40 | 53 |
|
41 | 54 |
|
55 |
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 |
|
|
42 | 64 |
|
43 | 65 |
print("Zadejte jméno Datasetu který chcete resetovat (pokud všechny zadejte '-ALL'):\n") |
44 | 66 |
|
45 | 67 |
dataset_name = input().upper() |
46 | 68 |
|
69 |
print("Chcete smazat i stažené stažená data ? (ANO/NE) \n") |
|
70 |
|
|
71 |
vstup = input().upper() |
|
72 |
|
|
47 | 73 |
if dataset_name == '-ALL': |
48 |
reset_all_datasets() |
|
74 |
if vstup == 'ANO': |
|
75 |
hard_reset_all_datasets() |
|
76 |
elif vstup == 'NE': |
|
77 |
soft_reset_all_datasets() |
|
78 |
else: |
|
79 |
print('Neplatný vstup (ANO/NE)') |
|
49 | 80 |
else: |
50 | 81 |
test = configure_functions.check_if_there_is_a_config_file(dataset_name) |
51 | 82 |
if test == True: |
52 |
reset_dataset(dataset_name) |
|
83 |
if vstup == 'ANO': |
|
84 |
hard_reset_dataset(dataset_name) |
|
85 |
elif vstup == 'NE': |
|
86 |
soft_reset_dataset(dataset_name) |
|
87 |
else: |
|
88 |
print('Neplatný vstup (ANO/NE)') |
|
53 | 89 |
else: |
54 | 90 |
print("Tento dataset v architektuře neexistuje") |
91 |
|
Také k dispozici: Unified diff
Predelany komentáře upravena kontrola datasetu