]> git.phdru.name Git - bookmarks_db.git/blobdiff - parse_html/bkmk_parse_html.py
Style: Fix flake8 E402 module level import not at top of file
[bookmarks_db.git] / parse_html / bkmk_parse_html.py
index 7bdc5664470b2c2ae4499be6f7519689daae4ae6..c14d055dfe9213556b48bf60fc4ee467d3888a39 100644 (file)
@@ -12,11 +12,7 @@ __all__ = ['parse_html', 'parse_filename', 'universal_charset']
 
 
 import codecs
-
-universal_charset = "utf-8"
-DEFAULT_CHARSET = "cp1251"  # Stupid default for Russian Cyrillic
-
-parsers = []
+import os
 
 try:
     from . import bkmk_ph_beautifulsoup4
@@ -66,9 +62,15 @@ else:
 import re
 from htmlentitydefs import name2codepoint
 
+universal_charset = "utf-8"
+DEFAULT_CHARSET = "cp1251"  # Stupid default for Russian Cyrillic
+
+parsers = []
+
 entity_re = re.compile("(&\w+;)")
 num_entity_re = re.compile("(&#[0-9]+;)")
 
+
 def recode_entities(title, charset):
     output = []
     for part in entity_re.split(title):
@@ -92,9 +94,9 @@ def recode_entities(title, charset):
     return ''.join(output)
 
 
-import os
 BKMK_DEBUG_HTML_PARSERS = os.environ.get("BKMK_DEBUG_HTML_PARSERS")
 
+
 def parse_html(html_text, charset=None, log=None):
     if not parsers:
         return None
@@ -211,6 +213,7 @@ def parse_html(html_text, charset=None, log=None):
                 parser.icon = icon.encode(parser.charset)
     return parser
 
+
 def parse_filename(filename, charset=None, log=None):
     fp = open(filename, 'r')
     try: