Top Documents Download Gallery Repository
Are you looking for a Software Engineer? Check Here

57yaml Module

The yaml module provides measures to read/write YAML files. You can use this module as a measure to serialize and deserialize objects that consists of list, dict and string instances.

Below is an example to reconstruct values from YAML text:

txt = '''
key1:
  - item-A
  - item-B
  - item-C
key2:
  - item-D
  - item-E
  - item-F
'''
x = yaml.parse(txt)
// x has the following value:
// %{
//   'key1' => ['item-A', 'item-B', 'item-C']
//   'key2' => ['item-D', 'item-E', 'item-F']
// }

57.1Correspondance of Data Object

The below table shows how YAML data types correspond to Gura's value types each other:

YAML Data Type Gura's Value Type
sequence list
mapping dict
scalar string

57.2Module Function

yaml.compose
yaml.compose(obj)
Composes YAML text to represent the content of obj that consists of list, dict and string instances.

yaml.parse
yaml.parse(str:string)
Parses YAML text in str and returns a composition of list, dict and string instances.

yaml.read
yaml.read(stream:stream:r)
Parses YAML text from stream and returns a composition of list, dict and string instances.

yaml.write
yaml.write(stream:stream:w, obj):reduce
Composes YAML text to represent the content of obj that consists of list, dict and string instances and writes the result to stream.

57.3Thanks

This module uses yaml library which is distributed in the following site:

http://pyyaml.org/wiki/LibYAML


Copyright (C) 2011-2017 ypsitau