Skip to content

Commit

Permalink
fix: typos and description of yaml_escape_list function
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekzyla committed Jul 27, 2023
1 parent 2420407 commit b947c2d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions backend/SC4SNMP_UI_backend/apply_changes/config_to_yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
"""
Expand Down Expand Up @@ -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
"""
Expand All @@ -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
"""
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit b947c2d

Please sign in to comment.