INNER CODE UNIT · Python
_Dumper
mongodb/mongo-c-driver · .evergreen/legacy_config_generator/evergreen_config_generator/__init__.py:65
class _Dumper(yamlloader.ordereddict.Dumper):
def __init__(self, *args: Value, **kwargs: Value):
super().__init__(*args, **kwargs) # type: ignore
self.add_representer(set, type(self).represent_set)
# Use "multi_representer" to represent all subclasses of ConfigObject.
self.add_multi_representer(ConfigObject, type(self).represent_config_object)
def represent_scalar(self, tag: str, value: Value, style: str | None = None) -> yaml.ScalarNode:
if isinstance(value, (str)) and '\n' in value:
style = '|'
return super().represent_scalar(tag, value, style) # type: ignore
def represent_set(self, data: Iterable[Value]) -> yaml.MappingNode:
return super().represent_list(sorted(set(data))) # type: ignore
def represent_config_object(self, obj: ConfigObject) -> yaml.Node:
d = obj.to_dict()
return super().represent_data(d) # type: ignore