コード例 #1
0
 def map(self, **kw):
     # type: (Any) -> Any
     if self.typ == 'rt':
         from ruamel_yaml.comments import CommentedMap
         return CommentedMap(**kw)
     else:
         return dict(**kw)
コード例 #2
0
    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
コード例 #3
0
ファイル: yaml_file.py プロジェクト: bollwyvl/kapsel
 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
コード例 #4
0
ファイル: yaml_file.py プロジェクト: conda/kapsel
 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