[Python-modules-commits] [python-tidylib] 01/01: Import python-tidylib_0.3.1~dfsg.orig.tar.gz

Dmitry Shachnev mitya57 at moszumanska.debian.org
Fri Oct 21 16:23:58 UTC 2016


This is an automated email from the git hooks/post-receive script.

mitya57 pushed a commit to branch upstream
in repository python-tidylib.

commit 59cfeaee9a339c1547dda021efa1c0498c536a4b
Author: Dmitry Shachnev <mitya57 at gmail.com>
Date:   Fri Oct 21 19:22:33 2016 +0300

    Import python-tidylib_0.3.1~dfsg.orig.tar.gz
---
 PKG-INFO                |  4 +++-
 setup.py                |  4 +++-
 tests/test_docs.py      |  8 ++++----
 tests/test_fragments.py |  8 ++++----
 tidylib/tidy.py         | 10 +++++++---
 5 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 8a64af2..5e6943e 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pytidylib
-Version: 0.3.0
+Version: 0.3.1
 Summary: Python wrapper for HTML Tidy (tidylib) on Python 2 and 3
 Home-page: http://countergram.com/open-source/pytidylib/
 Author: Jason Stitt
@@ -21,6 +21,8 @@ Description: `PyTidyLib`_ is a Python package that wraps the `HTML Tidy`_ librar
         Changes
         =======
         
+        * 0.3.1: find_library support while still allowing a list of library names
+        
         * 0.3.0: Refactored to use Tidy and PersistentTidy classes while keeping the
         functional interface (which will lazily create a global Tidy() object) for
         backward compatibility. You can now pass a list of library names and base
diff --git a/setup.py b/setup.py
index ceadc75..dbc673d 100644
--- a/setup.py
+++ b/setup.py
@@ -36,6 +36,8 @@ library's many capabilities include:
 Changes
 =======
 
+* 0.3.1: find_library support while still allowing a list of library names
+
 * 0.3.0: Refactored to use Tidy and PersistentTidy classes while keeping the
 functional interface (which will lazily create a global Tidy() object) for
 backward compatibility. You can now pass a list of library names and base
@@ -67,7 +69,7 @@ the `PyTidyLib`_ web page.
 .. _`PyTidyLib`: http://countergram.com/open-source/pytidylib/
 """
 
-VERSION = "0.3.0"
+VERSION = "0.3.1"
 
 setup(
     name="pytidylib",
diff --git a/tests/test_docs.py b/tests/test_docs.py
index adcffe4..ff2379f 100644
--- a/tests/test_docs.py
+++ b/tests/test_docs.py
@@ -48,20 +48,20 @@ class TestDocs1(unittest.TestCase):
 
     def test_alt_added_to_img(self):
         h = "<img src='foo'>"
-        expected = DOC % '''<img src='foo' alt="">'''
-        doc, err = tidy_document(h)
+        expected = DOC % '''<img src='foo' alt="bar">'''
+        doc, err = tidy_document(h, {'alt-text': 'bar'})
         self.assertEqual(doc, expected)
 
     def test_entity_preserved_using_bytes(self):
         h = b"é"
         expected = (DOC % "é").encode('utf-8')
-        doc, err = tidy_document(h)
+        doc, err = tidy_document(h, {'preserve-entities': 1})
         self.assertEqual(doc, expected)
 
     def test_numeric_entities_using_bytes(self):
         h = b"é"
         expected = (DOC % "é").encode('utf-8')
-        doc, err = tidy_document(h, {'numeric-entities': 1})
+        doc, err = tidy_document(h, {'numeric-entities': 1, 'output-encoding': 'ascii'})
         self.assertEqual(doc, expected)
 
     def test_non_ascii_preserved(self):
diff --git a/tests/test_fragments.py b/tests/test_fragments.py
index dcc7a3a..c329e15 100644
--- a/tests/test_fragments.py
+++ b/tests/test_fragments.py
@@ -36,20 +36,20 @@ class TestFrags1(unittest.TestCase):
 
     def test_alt_added_to_img(self):
         h = "<img src='foo'>"
-        expected = '''<img src='foo' alt="">'''
-        doc, err = tidy_fragment(h)
+        expected = '''<img src='foo' alt="bar">'''
+        doc, err = tidy_fragment(h, {'alt-text': 'bar'})
         self.assertEqual(doc, expected)
 
     def test_entity_preserved_using_bytes(self):
         h = b"é"
         expected = b"é"
-        doc, err = tidy_fragment(h)
+        doc, err = tidy_fragment(h, {'preserve-entities': 1})
         self.assertEqual(doc, expected)
 
     def test_numeric_entities_using_bytes(self):
         h = b"é"
         expected = b"é"
-        doc, err = tidy_fragment(h, {'numeric-entities': 1})
+        doc, err = tidy_fragment(h, {'numeric-entities': 1, 'output-encoding': 'ascii'})
         self.assertEqual(doc, expected)
 
     def test_non_ascii_preserved(self):
diff --git a/tidylib/tidy.py b/tidylib/tidy.py
index a71ae9f..d7fff95 100644
--- a/tidylib/tidy.py
+++ b/tidylib/tidy.py
@@ -19,6 +19,7 @@
 # THE SOFTWARE.
 
 import ctypes
+import ctypes.util
 import threading
 import platform
 import warnings
@@ -80,8 +81,11 @@ class Tidy(object):
     """ Wrapper around the HTML Tidy library for cleaning up possibly invalid
     HTML and XHTML. """
 
-    def __init__(self, lib_names=LIB_NAMES):
-        lib_names = lib_names if isinstance(lib_names, list) else [lib_names]
+    def __init__(self, lib_names=None):
+        if lib_names is None:
+            lib_names = ctypes.util.find_library('tidy') or LIB_NAMES
+        if isinstance(lib_names, str):
+            lib_names = [lib_names]
         for name in lib_names:
             try:
                 self._tidy = load_library(name)
@@ -194,7 +198,7 @@ class PersistentTidy(Tidy):
     automatically set. Thread-local storage is used for the document object
     (one document per thread). """
 
-    def __init__(self, lib_names=LIB_NAMES):
+    def __init__(self, lib_names=None):
         Tidy.__init__(self, lib_names)
         self._local = threading.local()
         self._local.doc = self._tidy.tidyCreate()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-tidylib.git



More information about the Python-modules-commits mailing list