This works for me:

from yaml import *;

tokens = (
    StreamStartEvent(),
    DocumentStartEvent(explicit=True),
    MappingStartEvent(anchor=None, tag=None, implicit=True),
    ScalarEvent(None, None, [1,1], 'value1', style=''),
    ScalarEvent(None, None, [1,1], '1', style=''),
    ScalarEvent(None, None, [1,1], 'value2', style=''),
    ScalarEvent(None, None, [1,1], 'line1\nline2\nline3', style='|'),
    MappingEndEvent(),
    DocumentEndEvent(),
    StreamEndEvent(),
)

print emit(tokens)

- Ingy

On Mon, Apr 6, 2009 at 2:59 PM, Andrey Somov <py4fun@gmail.com> wrote:
Hi All,
even though there is plenty of options while dumping YAML in PyYAML, I
could not find how I can mix different scalar styles in the same
document.
For instance, instead of:
---
value1: 1
value2: 'line1

    line2

   line3'
...
I would like to dump
---
value1: 1
value2: |-
    line1
    line2
    line3
...

So I would like to use the plain scalar style but if the value
contains '\n' then the literal style shall be used.
Is it possible?

Andrey

------------------------------------------------------------------------------
_______________________________________________
Yaml-core mailing list
Yaml-core@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/yaml-core