Revize 04a2b5a4
Přidáno uživatelem Petr Hlaváč před asi 4 roky(ů)
python-module/Utilities/ConfigureFunctions.py | ||
---|---|---|
1 | 1 |
import yaml |
2 | 2 |
|
3 |
# Path to dataset configuration files |
|
4 |
CONFIG_FILES_PATH = "DatasetConfigs/" |
|
5 |
# Config file type |
|
6 |
CONFIG_FILE_TYPE = ".yaml" |
|
3 | 7 |
|
4 |
def load_configuration(configure_file_name): |
|
5 | 8 |
|
6 |
with open(configure_file_name) as f: |
|
9 |
def load_configuration(dataset_name): |
|
10 |
""" |
|
11 |
Loads yaml configuration file into memory |
|
12 |
|
|
13 |
Args: |
|
14 |
dataset_name: name of dataset that has existing configuration file |
|
15 |
|
|
16 |
Returns: |
|
17 |
yaml configuration file as dictionary |
|
18 |
""" |
|
19 |
with open(CONFIG_FILES_PATH + dataset_name + CONFIG_FILE_TYPE, "r") as f: |
|
7 | 20 |
data = yaml.load(f, Loader=yaml.FullLoader) |
8 | 21 |
|
9 | 22 |
devices_dic = dict() |
... | ... | |
17 | 30 |
return data |
18 | 31 |
|
19 | 32 |
|
20 |
def update_configuration(configure_file_name, new_devices): |
|
33 |
def update_configuration(dataset_name, new_devices): |
|
34 |
""" |
|
35 |
Open dataset and appends new_devices to the end |
|
21 | 36 |
|
22 |
with open(configure_file_name, "a") as file: |
|
37 |
Args: |
|
38 |
dataset_name: name of dataset that has existing configuration file |
|
39 |
new_devices: list or set of new devices for dataset |
|
40 |
""" |
|
41 |
with open(CONFIG_FILES_PATH + dataset_name + CONFIG_FILE_TYPE, "a") as file: |
|
23 | 42 |
for device in new_devices: |
24 | 43 |
file.write(" - "+device+":\n") |
25 | 44 |
file.write(" x: UNKNOWN!\n") |
Také k dispozici: Unified diff
Re #7939
- pridana dokumentace metod a trid
- korekce chyb v jmenech promenych
- pridani informaci pro vygenerovane skripty