Ticket #154: 0001-Fix-custom-tags-in-pyyaml-interface.patch

File 0001-Fix-custom-tags-in-pyyaml-interface.patch, 2.4 KB (added by smichalske@…, 4 years ago)

Patch that makes the cloades construct custom tags.

  • lib/yaml/__init__.py

    From 4390e0e17cb76618d94523230cfca665aac0c93d Mon Sep 17 00:00:00 2001
    From: Steven Michalske <smichalske@gmail.com>
    Date: Thu, 5 Aug 2010 00:40:02 -0700
    Subject: [PATCH] Fix custom tags in pyyaml interface
    
    ---
     lib/yaml/__init__.py  |   11 +++++++++--
     lib3/yaml/__init__.py |   12 ++++++++++--
     2 files changed, 19 insertions(+), 4 deletions(-)
    
    diff --git a/lib/yaml/__init__.py b/lib/yaml/__init__.py
    index c0fd1f3..6e461b9 100644
    a b from dumper import * 
    1010 
    1111__version__ = '3.09' 
    1212 
     13Loaders = [Loader] 
     14Dumpers = [Dumper] 
     15 
    1316try: 
    1417    from cyaml import * 
    1518    __with_libyaml__ = True 
     19    Loaders.append(CLoader) 
     20    Dumpers.append(CDumper) 
    1621except ImportError: 
    1722    __with_libyaml__ = False 
    1823 
    class YAMLObjectMetaclass(type): 
    253258    def __init__(cls, name, bases, kwds): 
    254259        super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) 
    255260        if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None: 
    256             cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) 
    257             cls.yaml_dumper.add_representer(cls, cls.to_yaml) 
     261            for l in Loaders: 
     262                l.add_constructor(cls.yaml_tag, cls.from_yaml) 
     263            for d in Dumpers: 
     264                d.add_representer(cls, cls.to_yaml) 
    258265 
    259266class YAMLObject(object): 
    260267    """ 
  • lib3/yaml/__init__.py

    diff --git a/lib3/yaml/__init__.py b/lib3/yaml/__init__.py
    index cd2ea5a..994c708 100644
    a b from .loader import * 
    99from .dumper import * 
    1010 
    1111__version__ = '3.09' 
     12 
     13Loaders = [Loader] 
     14Dumpers = [Dumper] 
     15 
    1216try: 
    1317    from .cyaml import * 
    1418    __with_libyaml__ = True 
     19    Loaders.append(CLoader) 
     20    Dumpers.append(CDumper) 
    1521except ImportError: 
    1622    __with_libyaml__ = False 
    1723 
    class YAMLObjectMetaclass(type): 
    251257    def __init__(cls, name, bases, kwds): 
    252258        super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) 
    253259        if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None: 
    254             cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) 
    255             cls.yaml_dumper.add_representer(cls, cls.to_yaml) 
     260            for l in Loaders: 
     261                l.add_constructor(cls.yaml_tag, cls.from_yaml) 
     262            for d in Dumpers: 
     263                d.add_representer(cls, cls.to_yaml) 
    256264 
    257265class YAMLObject(metaclass=YAMLObjectMetaclass): 
    258266    """