From: Oleg Broytman Date: Sat, 16 Sep 2023 19:20:51 +0000 (+0300) Subject: Fix(Py3): Fix `unicode` compatibility X-Git-Tag: 5.0.0~74 X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=708b258fa37272ece656f6825e80dc6bcbae849e;p=bookmarks_db.git Fix(Py3): Fix `unicode` compatibility --- diff --git a/Writers/bkmk_wflad.py b/Writers/bkmk_wflad.py index 0d1acbb..1adc343 100644 --- a/Writers/bkmk_wflad.py +++ b/Writers/bkmk_wflad.py @@ -12,6 +12,7 @@ __all__ = ['writer_flad'] import time from bkmk_objects import Writer +from compat import unicode def strftime(s): diff --git a/Writers/bkmk_whtml.py b/Writers/bkmk_whtml.py index dd43b0d..09d9989 100644 --- a/Writers/bkmk_whtml.py +++ b/Writers/bkmk_whtml.py @@ -11,6 +11,7 @@ __all__ = ['writer_html'] from bkmk_objects import Writer, BKMK_FORMAT, quote_title +from compat import unicode def dump_comment(comment): diff --git a/compat.py b/compat.py new file mode 100644 index 0000000..ab6254c --- /dev/null +++ b/compat.py @@ -0,0 +1,11 @@ +import sys + +# Compatability definitions (inspired by six) +PY2 = sys.version_info[0] < 3 +if PY2: + # disable flake8 checks on python 3 + string_type = basestring # noqa + unicode = unicode # noqa +else: + string_type = str + unicode = str diff --git a/parse_html/bkmk_parse_html.py b/parse_html/bkmk_parse_html.py index 997bf64..8d6cb7c 100644 --- a/parse_html/bkmk_parse_html.py +++ b/parse_html/bkmk_parse_html.py @@ -14,6 +14,8 @@ __all__ = ['parse_html', 'parse_filename', 'universal_charset'] import codecs import os +from ..compat import unicode + try: from . import bkmk_ph_beautifulsoup4 except ImportError: