9 from constructor
import *
12 from serializer
import *
13 from representer
import *
15 from detector
import *
21 from yaml_object
import *
23 def parse(data
, Reader
=Reader
, Scanner
=Scanner
, Parser
=Parser
):
25 scanner
= Scanner(reader
)
26 parser
= Parser(scanner
)
29 def load_all(data
, Reader
=Reader
, Scanner
=Scanner
, Parser
=Parser
,
30 Composer
=Composer
, Resolver
=Resolver
, Constructor
=Constructor
):
32 scanner
= Scanner(reader
)
33 parser
= Parser(scanner
)
34 composer
= Composer(parser
)
35 resolver
= Resolver(composer
)
36 constructor
= Constructor(resolver
)
39 def safe_load_all(data
, Reader
=Reader
, Scanner
=Scanner
, Parser
=Parser
,
40 Composer
=Composer
, Resolver
=Resolver
, Constructor
=SafeConstructor
):
41 return load_all(data
, Reader
, Scanner
, Parser
, Composer
, Resolver
,
44 def load(data
, *args
, **kwds
):
45 for document
in load_all(data
, *args
, **kwds
):
48 def safe_load(data
, *args
, **kwds
):
49 for document
in safe_load_all(data
, *args
, **kwds
):
52 def emit(events
, writer
=None, Emitter
=Emitter
):
55 from cStringIO
import StringIO
57 from StringIO
import StringIO
62 emitter
= Emitter(writer
)
66 return writer
.getvalue()
68 def dump_all(natives
, writer
=None, Emitter
=Emitter
,
69 Serializer
=Serializer
, Representer
=Representer
,
70 encoding
='utf-8', line_break
=None, canonical
=None,
71 indent
=None, width
=None, allow_unicode
=None):
74 from cStringIO
import StringIO
76 from StringIO
import StringIO
81 emitter
= Emitter(writer
)
82 serializer
= Serializer(emitter
, encoding
=encoding
, line_break
=line_break
,
83 canonical
=canonical
, indent
=indent
, width
=width
,
84 allow_unicode
=allow_unicode
)
85 representer
= Representer(serializer
)
86 for native
in natives
:
87 representer
.represent(native
)
90 return writer
.getvalue()
92 def safe_dump_all(natives
, writer
=None, Emitter
=Emitter
,
93 Serializer
=Serializer
, Representer
=SafeRepresenter
,
94 encoding
='utf-8', line_break
=None, canonical
=None,
95 indent
=None, width
=None, allow_unicode
=None):
96 return dump_all(natives
, writer
, Emitter
, Serializer
, Representer
,
97 encoding
, line_break
, canonical
, indent
, width
, allow_unicode
)
99 def dump(native
, *args
, **kwds
):
100 return dump_all([native
], *args
, **kwds
)
102 def safe_dump(native
, *args
, **kwds
):
103 return safe_dump_all([native
], *args
, **kwds
)