Beispiel #1
0
    def yatiml_savorize(cls, node: yatiml.Node) -> None:
        text = str(node.get_value())
        parts = text.split('.')
        node.make_mapping()

        # We need to make a yaml.SequenceNode by hand here, since
        # set_attribute doesn't take lists as an argument.
        start_mark = yaml.error.StreamMark('generated node', 0, 0, 0)
        end_mark = yaml.error.StreamMark('generated node', 0, 0, 0)
        item_nodes = list()
        for part in parts[:-1]:
            item_nodes.append(
                yaml.ScalarNode('tag:yaml.org,2002:str', part, start_mark,
                                end_mark))
        ynode = yaml.SequenceNode('tag:yaml.org,2002:seq', item_nodes,
                                  start_mark, end_mark)
        node.set_attribute('namespaces', ynode)
        node.set_attribute('name', parts[-1])
Beispiel #2
0
def test_make_mapping(scalar_node: yatiml.Node) -> None:
    assert scalar_node.is_scalar(int)
    scalar_node.make_mapping()
    assert isinstance(scalar_node.yaml_node, yaml.MappingNode)
    assert scalar_node.yaml_node.tag == 'tag:yaml.org,2002:map'
    assert scalar_node.yaml_node.value == []
Beispiel #3
0
 def yatiml_savorize(cls, node: yatiml.Node) -> None:
     text = str(node.get_value())
     node.make_mapping()
     node.set_attribute('digits', int(text[0:4]))
     node.set_attribute('letters', text[5:7])
Beispiel #4
0
 def _yatiml_savorize(cls, node: yatiml.Node) -> None:
     # wrap the existing mapping into a new mapping with attribute settings
     setting_values = node.yaml_node
     node.make_mapping()
     node.set_attribute('settings', setting_values)