def map(self, **kw): # type: (Any) -> Any if self.typ == 'rt': from ruamel_yaml.comments import CommentedMap return CommentedMap(**kw) else: return dict(**kw)
def _ensure_dicts_at_path(self, pieces): self._throw_if_corrupted() current = self._yaml for p in pieces: if p not in current or not isinstance(current[p], dict): # It's important to use CommentedMap because it preserves # order. current[p] = CommentedMap() _block_style_all_nodes(current[p]) current = current[p] return current
def _default_content(self): # ruamel.yaml returns None if you load an empty file, # so we have to build this ourselves root = CommentedMap() root.yaml_set_start_comment(self._default_comment()) return root