aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--README.txt22
-rw-r--r--setup.py19
-rw-r--r--test/__init__.py5
-rw-r--r--test/test_input.py5
-rw-r--r--test/test_load.py5
-rw-r--r--test/test_output.py5
-rw-r--r--test/test_reader.py5
-rw-r--r--test/test_writer.py5
-rw-r--r--yamlish.py9
9 files changed, 55 insertions, 25 deletions
diff --git a/README.txt b/README.txt
index 698f5de..8858694 100644
--- a/README.txt
+++ b/README.txt
@@ -1,13 +1,15 @@
-YAMLish is a small subset of YAML that TAP producers may use to embed machine readable
-information in TAP diagnostics. See TAP diagnostic syntax for information about how
-YAMLish embeds in TAP.
+YAMLish is a small subset of YAML that TAP producers may use to
+embed machine readable information in TAP diagnostics. See TAP
+diagnostic syntax for information about how YAMLish embeds in
+TAP.
----------------------------
-Based on Data-YAML version 0.0.6 (Copyright (C) 2007, Andy Armstrong), but it
-is so thoroughly rewritten that I don't consider it derived work and I don't
-feel the need to resolve what "This library is free software; you can
-redistribute it and/or modify it under the same terms as Perl itself." actually
-means.
+Based on Data-YAML version 0.0.6
+(Copyright (C) 2007, Andy Armstrong)
+but it is so thoroughly rewritten that I don't consider it
+derived work and I don't feel the need to resolve what "This
+library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself." actually means.
-Whole this package is licensed under MIT/X11 license (see header of yamlish.py
-for details).
+Whole this package is licensed under MIT/X11 license (see header
+of yamlish.py for details).
diff --git a/setup.py b/setup.py
index da697e1..9cd4961 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,17 @@
# coding: utf-8
-from __future__ import absolute_import, print_function, unicode_literals
+from __future__ import absolute_import, print_function
from distutils.core import setup, Command
-import unittest2 as unittest
+import sys
+requires_list = [
+ "PyYAML (>=3.09)"
+ ]
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+else:
+ if sys.version_info <= (2 , 6):
+ requires_list.append("unittest2")
import os.path
import yamlish
@@ -51,8 +61,5 @@ setup(
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Text Processing :: Markup",
],
- requires=[
- "PyYAML (>=3.09)",
- "unittest2"
- ],
+ requires=requires_list
)
diff --git a/test/__init__.py b/test/__init__.py
index 83cdd6d..05ba3b2 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -2,7 +2,10 @@
from __future__ import absolute_import, print_function, unicode_literals
import logging
import yamlish
-import unittest2 as unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import yaml
import tempfile
import textwrap
diff --git a/test/test_input.py b/test/test_input.py
index cfd4142..6b5c5ca 100644
--- a/test/test_input.py
+++ b/test/test_input.py
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
import test
-import unittest2 as unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import yamlish
test_data_list = [
diff --git a/test/test_load.py b/test/test_load.py
index b5ac95e..7a76ae1 100644
--- a/test/test_load.py
+++ b/test/test_load.py
@@ -1,6 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
-import unittest2 as unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
class TestBasics(unittest.TestCase):
def test_import(self):
diff --git a/test/test_output.py b/test/test_output.py
index 888f812..1105b84 100644
--- a/test/test_output.py
+++ b/test/test_output.py
@@ -5,7 +5,10 @@ Test general output functionality.
Without much stress on the format itself.
"""
from __future__ import absolute_import, print_function, unicode_literals
-import unittest2 as unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import yamlish
import yaml
import logging
diff --git a/test/test_reader.py b/test/test_reader.py
index 0676b30..a34104c 100644
--- a/test/test_reader.py
+++ b/test/test_reader.py
@@ -3,7 +3,10 @@ from __future__ import absolute_import, print_function, unicode_literals
import yaml
import yamlish
import test
-import unittest2 as unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
test_data_list = [
{
diff --git a/test/test_writer.py b/test/test_writer.py
index 7d9e690..a3f3893 100644
--- a/test/test_writer.py
+++ b/test/test_writer.py
@@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
-import unittest2 as unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
import test
import yamlish
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):
"""