Commits

Takayuki Shimizukawa committed 7aefa48

fix some code for py24,py25,py32.

Comments (0)

Files changed (5)

docutils_textile/__init__.py

-from __future__ import absolute_import
 """
 docutils textile.
 
 
 __docformat__ = 'reStructuredText'
 
-from .writer import TextileWriter as Writer  #for docutils rule.
+from docutils_textile.writer import TextileWriter as Writer  #for docutils rule.
     #if docutils receive 'foo' as writer name, execute `import foo.Writer`.
 
 
 # setup hook for sphinx
 def setup(app):
-    from .builder import SphinxTextileBuilder
+    from docutils_textile.builder import SphinxTextileBuilder
     app.add_builder(SphinxTextileBuilder)  #sphinx builder registration

docutils_textile/builder.py

 # -*- coding: utf8 -*-
-from __future__ import absolute_import
 """
 docutils textile builder.
 
 except ImportError:
     raise ImportError("sphinx: you NEED Sphinx installation if you want to use `docutils_textile.builder`.")
 
-from .writer import TextileWriter, TextileTranslator
+from docutils_textile.writer import TextileWriter, TextileTranslator
 
 
 class SphinxTextileTranslator(TextileTranslator):

docutils_textile/main.py

 #!/usr/bin/python
 #-*- coding: utf-8 -*-
-from __future__ import absolute_import
 """
 docutils textile.
 
 #!/usr/bin/python
 #-*- coding: utf-8 -*-
-from __future__ import absolute_import
 """
 rst2textile.
 
-from __future__ import absolute_import
-
-import io
+import sys
 import unittest
 import textwrap
 import docutils.core
 import docutils.writers
 
 
+if sys.version_info >= (3, 0):
+    py3 = True
+else:
+    py3 = False
+
+
 WRITER_ALIASES = {
     'textile': 'docutils_textile',
 }
             actual = docutils.core.publish_string(
                     source,
                     parser_name=_from,
-                    writer_name=_to)
+                    writer_name=_to,
+                    settings_overrides={'output_encoding': 'unicode'})
             actual = actual.strip()
             node_tree = docutils.core.publish_string(
                     source,
 class ReSTTestSuite(unittest.TestSuite):
 
     def __init__(self, filename):
-        with io.open(filename, 'rt', encoding='utf8') as f:
-            tests = docutils.core.publish_string(
-                    source=f.read(), source_path=f.name,
-                    writer=DocutilsTestWriter())
+        f = open(filename, 'rt')
+        data = f.read()
+        if not py3:
+            data = data.decode('utf8')
+        tests = docutils.core.publish_string(
+                source=data, source_path=f.name,
+                writer=DocutilsTestWriter())
+        f.close()
         unittest.TestSuite.__init__(self, tests)