aboutsummaryrefslogtreecommitdiffstats
path: root/yamlish.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2012-04-16 23:50:15 +0200
committerMatěj Cepl <mcepl@redhat.com>2012-04-17 00:57:13 +0200
commitdbd47fe3e0002d9a9c1975075d7435a15b87fb51 (patch)
tree7151c83eb63662e02defda884d7e97359d256bfb /yamlish.py
parentd7b122f17ebc23b0ea8bd0cf1df3bc854a9a595b (diff)
downloadyamlish-dbd47fe3e0002d9a9c1975075d7435a15b87fb51.tar.gz
Make the package compatible with python 2.70.9
There is actually unittest module now, so we have to work for the possibility that unittest2 is not available. Fixes #49.
Diffstat (limited to 'yamlish.py')
-rw-r--r--yamlish.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/yamlish.py b/yamlish.py
index bf17993..c5bdfb0 100644
--- a/yamlish.py
+++ b/yamlish.py
@@ -113,8 +113,8 @@ import logging
import yaml
__docformat__ = 'reStructuredText'
-__version__ = "0.7"
-__author__ = "Matej Cepl <mcepl_at_redhat_dot_com>"
+__version__ = "0.9"
+__author__ = u"Matěj Cepl <mcepl_at_redhat_dot_com>"
class _YamlishLoader(yaml.loader.SafeLoader):
"""
@@ -149,12 +149,15 @@ def str_representer_compact_multiline(dumper, data):
style = None
if '\n' in data:
style = '|'
- data = data.decode('utf-8') # assumes all your strings are UTF-8 encoded
+ if isinstance(data, str):
+ data = data.decode('utf-8') # assumes all your strings are UTF-8 encoded
tag = u'tag:yaml.org,2002:str'
return dumper.represent_scalar(tag, data, style)
yaml.add_representer(str, str_representer_compact_multiline,
Dumper=_YamlishDumper)
+yaml.add_representer(unicode, str_representer_compact_multiline,
+ Dumper=_YamlishDumper)
def load(source):
"""