From d4a66178c39944d42f7b0211fc041bf7d6f1e21d Mon Sep 17 00:00:00 2001 From: Sam Sneddon Date: Sat, 29 Feb 2020 13:15:40 +0000 Subject: [PATCH 1/2] Drop datrie support --- CHANGES.rst | 17 +++++++++++++++ README.rst | 3 --- debug-info.py | 2 +- html5lib/_trie/__init__.py | 13 +---------- html5lib/_trie/datrie.py | 44 -------------------------------------- requirements-optional.txt | 6 ------ setup.py | 3 +-- 7 files changed, 20 insertions(+), 68 deletions(-) delete mode 100644 html5lib/_trie/datrie.py diff --git a/CHANGES.rst b/CHANGES.rst index 82605a21..46670446 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,23 @@ Change Log ---------- +1.1 +~~~ + +UNRELEASED + +Breaking changes: + +* Drop support for Python 3.3. (#358) +* Drop support for Python 3.4. (#421) + +Other changes: + +* Try to import from `collections.abc` to remove DeprecationWarning and ensure + `html5lib` keeps working in future Python versions. (#403) +* Drop optional `datrie` dependency. (#442) + + 1.0.1 ~~~~~ diff --git a/README.rst b/README.rst index fb9398f6..cec41d71 100644 --- a/README.rst +++ b/README.rst @@ -107,9 +107,6 @@ Optional Dependencies The following third-party libraries may be used for additional functionality: -- ``datrie`` can be used under CPython to improve parsing performance - (though in almost all cases the improvement is marginal); - - ``lxml`` is supported as a tree format (for both building and walking) under CPython (but *not* PyPy where it is known to cause segfaults); diff --git a/debug-info.py b/debug-info.py index f93fbdbe..b47b8ebf 100644 --- a/debug-info.py +++ b/debug-info.py @@ -12,7 +12,7 @@ "maxsize": sys.maxsize } -search_modules = ["chardet", "datrie", "genshi", "html5lib", "lxml", "six"] +search_modules = ["chardet", "genshi", "html5lib", "lxml", "six"] found_modules = [] for m in search_modules: diff --git a/html5lib/_trie/__init__.py b/html5lib/_trie/__init__.py index a5ba4bf1..edfdd527 100644 --- a/html5lib/_trie/__init__.py +++ b/html5lib/_trie/__init__.py @@ -1,14 +1,3 @@ from __future__ import absolute_import, division, unicode_literals -from .py import Trie as PyTrie - -Trie = PyTrie - -# pylint:disable=wrong-import-position -try: - from .datrie import Trie as DATrie -except ImportError: - pass -else: - Trie = DATrie -# pylint:enable=wrong-import-position +from .py import Trie diff --git a/html5lib/_trie/datrie.py b/html5lib/_trie/datrie.py deleted file mode 100644 index 51f3d046..00000000 --- a/html5lib/_trie/datrie.py +++ /dev/null @@ -1,44 +0,0 @@ -from __future__ import absolute_import, division, unicode_literals - -from datrie import Trie as DATrie -from six import text_type - -from ._base import Trie as ABCTrie - - -class Trie(ABCTrie): - def __init__(self, data): - chars = set() - for key in data.keys(): - if not isinstance(key, text_type): - raise TypeError("All keys must be strings") - for char in key: - chars.add(char) - - self._data = DATrie("".join(chars)) - for key, value in data.items(): - self._data[key] = value - - def __contains__(self, key): - return key in self._data - - def __len__(self): - return len(self._data) - - def __iter__(self): - raise NotImplementedError() - - def __getitem__(self, key): - return self._data[key] - - def keys(self, prefix=None): - return self._data.keys(prefix) - - def has_keys_with_prefix(self, prefix): - return self._data.has_keys_with_prefix(prefix) - - def longest_prefix(self, prefix): - return self._data.longest_prefix(prefix) - - def longest_prefix_item(self, prefix): - return self._data.longest_prefix_item(prefix) diff --git a/requirements-optional.txt b/requirements-optional.txt index d8be39ff..2e78c952 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -11,9 +11,3 @@ chardet>=2.2 # lxml is supported with its own treebuilder ("lxml") and otherwise # uses the standard ElementTree support lxml ; platform_python_implementation == 'CPython' - -# DATrie can be used in place of our Python trie implementation for -# slightly better parsing performance. -# https://github.com/pytries/datrie/issues/52 although closed is not -# yet released to https://pypi.org/project/datrie -datrie ; platform_python_implementation == 'CPython' and python_version < '3.7' diff --git a/setup.py b/setup.py index d3841290..f84c1284 100644 --- a/setup.py +++ b/setup.py @@ -111,7 +111,6 @@ def default_environment(): extras_require={ # A conditional extra will only install these items when the extra is # requested and the condition matches. - "datrie:platform_python_implementation == 'CPython'": ["datrie"], "lxml:platform_python_implementation == 'CPython'": ["lxml"], # Standard extras, will be installed when the extra is requested. @@ -123,6 +122,6 @@ def default_environment(): # extra that will be installed whenever the condition matches and the # all extra is requested. "all": ["genshi", "chardet>=2.2"], - "all:platform_python_implementation == 'CPython'": ["datrie", "lxml"], + "all:platform_python_implementation == 'CPython'": ["lxml"], }, ) From 0fe7acd226a0d0762fe5e05771858ab6f854c32b Mon Sep 17 00:00:00 2001 From: Sam Sneddon Date: Sun, 24 May 2020 03:35:43 +0100 Subject: [PATCH 2/2] fixup! Drop datrie support --- html5lib/_trie/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/html5lib/_trie/__init__.py b/html5lib/_trie/__init__.py index edfdd527..07bad5d3 100644 --- a/html5lib/_trie/__init__.py +++ b/html5lib/_trie/__init__.py @@ -1,3 +1,5 @@ from __future__ import absolute_import, division, unicode_literals from .py import Trie + +__all__ = ["Trie"] pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy