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 * |
| 10 | 10 | |
| 11 | 11 | __version__ = '3.09' |
| 12 | 12 | |
| | 13 | Loaders = [Loader] |
| | 14 | Dumpers = [Dumper] |
| | 15 | |
| 13 | 16 | try: |
| 14 | 17 | from cyaml import * |
| 15 | 18 | __with_libyaml__ = True |
| | 19 | Loaders.append(CLoader) |
| | 20 | Dumpers.append(CDumper) |
| 16 | 21 | except ImportError: |
| 17 | 22 | __with_libyaml__ = False |
| 18 | 23 | |
| … |
… |
class YAMLObjectMetaclass(type): |
| 253 | 258 | def __init__(cls, name, bases, kwds): |
| 254 | 259 | super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) |
| 255 | 260 | 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) |
| 258 | 265 | |
| 259 | 266 | class YAMLObject(object): |
| 260 | 267 | """ |
diff --git a/lib3/yaml/__init__.py b/lib3/yaml/__init__.py
index cd2ea5a..994c708 100644
|
a
|
b
|
from .loader import * |
| 9 | 9 | from .dumper import * |
| 10 | 10 | |
| 11 | 11 | __version__ = '3.09' |
| | 12 | |
| | 13 | Loaders = [Loader] |
| | 14 | Dumpers = [Dumper] |
| | 15 | |
| 12 | 16 | try: |
| 13 | 17 | from .cyaml import * |
| 14 | 18 | __with_libyaml__ = True |
| | 19 | Loaders.append(CLoader) |
| | 20 | Dumpers.append(CDumper) |
| 15 | 21 | except ImportError: |
| 16 | 22 | __with_libyaml__ = False |
| 17 | 23 | |
| … |
… |
class YAMLObjectMetaclass(type): |
| 251 | 257 | def __init__(cls, name, bases, kwds): |
| 252 | 258 | super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) |
| 253 | 259 | 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) |
| 256 | 264 | |
| 257 | 265 | class YAMLObject(metaclass=YAMLObjectMetaclass): |
| 258 | 266 | """ |