]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Py3): Fix `unicode` compatibility
authorOleg Broytman <phd@phdru.name>
Sat, 16 Sep 2023 19:20:51 +0000 (22:20 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 12 Nov 2023 10:29:01 +0000 (13:29 +0300)
Writers/bkmk_wflad.py
Writers/bkmk_whtml.py
compat.py [new file with mode: 0644]
parse_html/bkmk_parse_html.py

index 0d1acbb96d1d896e49ef6e5e4fbca1924f5e15b1..1adc34310b9c74be278c5ec6addb573243f8fa32 100644 (file)
@@ -12,6 +12,7 @@ __all__ = ['writer_flad']
 
 import time
 from bkmk_objects import Writer
+from compat import unicode
 
 
 def strftime(s):
index dd43b0d20b2bcd1be9b94b93b2657e9015811235..09d99894935d180d78ce2608be8fc611287a56d5 100644 (file)
@@ -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 (file)
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
index 997bf6489c9a2e49a44c74d1062a61aa85191cf5..8d6cb7c4e121d7e2a7b99c571e524ff75accf98c 100644 (file)
@@ -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: