From b947c2d1a59cc355072743fe6a2ef15471661cc4 Mon Sep 17 00:00:00 2001 From: Wojciech Zyla Date: Thu, 27 Jul 2023 10:18:55 +0200 Subject: [PATCH] fix: typos and description of yaml_escape_list function --- .../apply_changes/config_to_yaml_utils.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/SC4SNMP_UI_backend/apply_changes/config_to_yaml_utils.py b/backend/SC4SNMP_UI_backend/apply_changes/config_to_yaml_utils.py index 0a798b2..2ed1900 100644 --- a/backend/SC4SNMP_UI_backend/apply_changes/config_to_yaml_utils.py +++ b/backend/SC4SNMP_UI_backend/apply_changes/config_to_yaml_utils.py @@ -23,6 +23,14 @@ class MongoToYamlDictConversion: """ @classmethod def yaml_escape_list(cls, *l): + """ + This function is used to parse an example list [yaml_escape_list(el1, el2, el3)] like this: + - [el1, el2, el3] + and not like this: + - el1 + - el2 + - el3 + """ ret = ruamel.yaml.comments.CommentedSeq(l) ret.fa.set_flow_style() return ret @@ -35,7 +43,7 @@ class ProfilesToYamlDictConversion(MongoToYamlDictConversion): def convert(self, documents: list) -> dict: """ ProfilesToYamlDictConversion converts profiles from mongo collection to - format that can be dumped to yaml file + format that can be dumped to yaml file :param documents: list of profiles from mongo :return: dictionary that can be dumped to yaml """ @@ -92,7 +100,7 @@ class GroupsToYamlDictConversion(MongoToYamlDictConversion): def convert(self, documents: list) -> dict: """ GroupsToYamlDictConversion converts groups from mongo collection to - format that can be dumped to yaml file + format that can be dumped to yaml file :param documents: list of groups from mongo :return: dictionary that can be dumped to yaml """ @@ -118,7 +126,7 @@ class InventoryToYamlDictConversion(MongoToYamlDictConversion): def convert(self, documents: list) -> dict: """ InventoryToYamlDictConversion converts inventory from mongo collection to - format that can be dumped to yaml file + format that can be dumped to yaml file :param documents: inventory from mongo :return: dictionary that can be dumped to yaml """ @@ -175,7 +183,7 @@ def parse_dict_to_yaml(self, document: dict, delete_tmp: bool = True): with open(self._file_path, "r") as file: line = file.readline() while line != "": - lines += f"{line}" + lines += line line = file.readline() if delete_tmp: self._delete_temp() @@ -217,7 +225,7 @@ def parse_dict_to_yaml(self, document: dict, delete_tmp: bool = True): with open(self._file_path, "r") as file: line = file.readline() while line != "": - lines += f"{line}" + lines += line line = file.readline() if delete_tmp: self._delete_temp()