espnet2.utils.yaml_no_alias_safe_dump.yaml_no_alias_safe_dump
espnet2.utils.yaml_no_alias_safe_dump.yaml_no_alias_safe_dump
espnet2.utils.yaml_no_alias_safe_dump.yaml_no_alias_safe_dump(data, stream=None, **kwargs)
Safe-dump in YAML format without using anchors or aliases.
This function utilizes the NoAliasSafeDumper to ensure that the output YAML does not include any anchors or aliases, which can sometimes make the output less readable. This is particularly useful when the YAML output is intended for presentation or logging purposes.
Args: : data (Any): The data to be serialized to YAML format. stream (file-like object, optional): The stream to which the YAML data <br/>
will be written. If not provided, the function returns the YAML as a string. <br/>
**
<br/> kwargs: Additional keyword arguments to be passed to the yaml.dump : function.
Returns: : str or None: Returns the YAML representation of the data as a string if stream is not provided. Otherwise, returns None.
Examples: : ```python
yaml_no_alias_safe_dump({'name': 'John', 'age': 30}) 'age: 30
name: John ‘
>>> with open('output.yaml', 'w') as f: ... yaml_no_alias_safe_dump({'name': 'John', 'age': 30}, stream=f)
Note: : This function requires the PyYAML library to be installed.
Raises: : yaml.YAMLError: If an error occurs during the YAML serialization process.