Skip to content

Commit b5b10e7

Browse files
committed
modeling: parsing: data dump from instances of class 'Renamed'
1 parent c375cf2 commit b5b10e7

File tree

1 file changed

+7
-4
lines changed
  • manager/knot_resolver_manager/utils/modeling

1 file changed

+7
-4
lines changed

manager/knot_resolver_manager/utils/modeling/parsing.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from yaml.nodes import MappingNode
88

99
from .exceptions import DataParsingError
10-
from .renaming import renamed
10+
from .renaming import Renamed, renamed
1111

1212

1313
# custom hook for 'json.loads()' to detect duplicate keys in data
@@ -63,11 +63,14 @@ def parse_to_dict(self, text: str) -> Any:
6363
else:
6464
raise NotImplementedError(f"Parsing of format '{self}' is not implemented")
6565

66-
def dict_dump(self, data: Dict[str, Any]) -> str:
66+
def dict_dump(self, data: Union[Dict[str, Any], Renamed], indent: Optional[int] = None) -> str:
67+
if isinstance(data, Renamed):
68+
data = data.original()
69+
6770
if self is DataFormat.YAML:
68-
return yaml.safe_dump(data) # type: ignore
71+
return yaml.safe_dump(data, indent=indent) # type: ignore
6972
elif self is DataFormat.JSON:
70-
return json.dumps(data)
73+
return json.dumps(data, indent=indent)
7174
else:
7275
raise NotImplementedError(f"Exporting to '{self}' format is not implemented")
7376

0 commit comments

Comments
 (0)