Revize 81980e82
Přidáno uživatelem Tomáš Ballák před téměř 4 roky(ů)
modules/crawler/Utilities/configure_functions.py | ||
---|---|---|
1 | 1 |
import yaml |
2 | 2 |
import os |
3 | 3 |
from Utilities.Database import database_record_logs |
4 |
from Utilities.helpers import should_skip |
|
4 | 5 |
|
5 | 6 |
# Path to dataset configuration files |
6 | 7 |
CONFIG_FILES_PATH = "DatasetConfigs/" |
... | ... | |
41 | 42 |
new_devices: list or set of new devices for dataset |
42 | 43 |
""" |
43 | 44 |
|
44 |
with open(CONFIG_FILES_PATH + dataset_name + CONFIG_FILE_TYPE, "a") as file: |
|
45 |
with open(CONFIG_FILES_PATH + dataset_name + CONFIG_FILE_TYPE, |
|
46 |
"a") as file: |
|
45 | 47 |
for device in new_devices: |
46 |
file.write(" - "+device+":\n") |
|
48 |
if device == "": |
|
49 |
continue |
|
50 |
file.write(" - " + device + ":\n") |
|
47 | 51 |
file.write(" x: UNKNOWN!\n") |
48 | 52 |
file.write(" y: UNKNOWN!\n") |
49 | 53 |
file.write("\n") |
... | ... | |
65 | 69 |
|
66 | 70 |
for dataset in datasets: |
67 | 71 |
name = dataset.split('.') |
68 |
if name[0] == dataset_name :
|
|
72 |
if name[0] == dataset_name: |
|
69 | 73 |
return True |
70 | 74 |
|
71 | 75 |
return False |
72 | 76 |
|
77 |
|
|
73 | 78 |
def return_dictionary_of_valid_devices(devices): |
74 | 79 |
""" |
75 | 80 |
Iterates over all devices specified in config file |
... | ... | |
85 | 90 |
valid_devices = dict() |
86 | 91 |
|
87 | 92 |
for device in devices.keys(): |
88 |
x = devices[device]['x'] |
|
89 |
y = devices[device]['y'] |
|
90 |
if not (x == "SKIP" or x == "UNKNOWN!" or y == "SKIP" or y == "UNKNOWN!"): |
|
91 |
valid_devices[device] = {'name': device, 'x': x , 'y': y} |
|
93 |
if not should_skip(devices[device]): |
|
94 |
valid_devices[device] = { |
|
95 |
'name': device, |
|
96 |
'x': devices[device]['x'], |
|
97 |
'y': devices[device]['y'] |
|
98 |
} |
|
92 | 99 |
|
93 | 100 |
return valid_devices |
Také k dispozici: Unified diff
Re #8160 new dataset