Python yaml.representer() Examples

The following are 3 code examples of yaml.representer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module yaml , or try the search function .
Example #1
Source File: yaml_representers.py    From commcare-cloud with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def change_style(style, representer):
    def new_representer(dumper, data):
        scalar = representer(dumper, data)
        scalar.style = style
        return scalar
    return new_representer 
Example #2
Source File: odyldo.py    From hiyapyco with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        yaml.SafeDumper.__init__(self, *args, **kwargs)
        yaml.representer.SafeRepresenter.add_representer(OrderedDict, type(self)._odyrepr) 
Example #3
Source File: odyldo.py    From hiyapyco with GNU General Public License v3.0 5 votes vote down vote up
def _odyrepr(self, data):
        """see: yaml.representer.represent_mapping"""
        return self.represent_mapping('tag:yaml.org,2002:map', data.items())