]> git.phdru.name Git - bookmarks_db.git/commitdiff
Fix(Py3): Fix `basestring` compatibility
authorOleg Broytman <phd@phdru.name>
Sat, 16 Sep 2023 19:26:28 +0000 (22:26 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 12 Nov 2023 10:29:31 +0000 (13:29 +0300)
parse_html/bkmk_ph_beautifulsoup.py
parse_html/bkmk_ph_beautifulsoup4.py

index e29b4997932d764d29ebc290b9f407ec796a8063..888f868818deaf4d93e30fab6e21957799af9bc7 100644 (file)
@@ -14,7 +14,9 @@ __all__ = ['parse_html']
 import re
 from sgmllib import SGMLParser, SGMLParseError
 from BeautifulSoup import BeautifulSoup, CData
+
 from .bkmk_ph_util import HTMLParser
+from ..compat import string_type
 
 DEFAULT_CHARSET = "cp1251"  # Stupid default for Russian Cyrillic
 
@@ -95,7 +97,7 @@ def parse_html(html_text, charset=None, log=None):
         else:
             parts = []
             for part in title:
-                if not isinstance(part, basestring):
+                if not isinstance(part, string_type):
                     part = part.decode()
                 parts.append(part.strip())
             title = ''.join(parts)
index 1f77eb794be2c849f4eee824bb4ddbd62eb44488..33a2e18dd65376c1794c94d22b41c174212a24cb 100644 (file)
@@ -12,7 +12,9 @@ __all__ = ['parse_html']
 
 
 from bs4 import BeautifulSoup
+
 from .bkmk_ph_util import HTMLParser
+from ..compat import string_type
 
 universal_charset = "utf-8"
 DEFAULT_CHARSET = "cp1251"  # Stupid default for Russian Cyrillic
@@ -54,7 +56,7 @@ def parse_html(html_text, charset=None, log=None):
         else:
             parts = []
             for part in title:
-                if not isinstance(part, basestring):
+                if not isinstance(part, string_type):
                     part = part.decode()
                 parts.append(part.strip())
             title = ''.join(parts)