From d76fa989d1dce2cbce9295ea3299287656489293 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 15 Dec 2022 13:24:00 -0600 Subject: [PATCH] Fix encoding auto/chardet --- fanficfare/configurable.py | 10 ++-------- fanficfare/requestable.py | 5 +++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index ceb10ba4..e386589f 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -34,11 +34,6 @@ from .six import string_types as basestring import logging logger = logging.getLogger(__name__) -try: - import chardet -except ImportError: - chardet = None - from . import exceptions from . import fetchers from .fetchers import fetcher_nsapa_proxy @@ -47,7 +42,6 @@ from .fetchers import fetcher_flaresolverr_proxy ## has to be up here for brotli-dict to load correctly. from .browsercache import BrowserCache - # All of the writers(epub,html,txt) and adapters(ffnet,twlt,etc) # inherit from Configurable. The config file(s) uses ini format: # [sections] with key:value settings. @@ -1100,11 +1094,11 @@ class Configuration(ConfigParser): self.get_fetcher(make_new=True) def get_browser_cache(self): - logger.debug("1configuration.get_browser_cache:%s"%self.browser_cache) + # logger.debug("1configuration.get_browser_cache:%s"%self.browser_cache) if self.browser_cache is None: # force generation of browser cache if not there self.get_fetcher() - logger.debug("2configuration.get_browser_cache:%s"%self.browser_cache) + # logger.debug("2configuration.get_browser_cache:%s"%self.browser_cache) return self.browser_cache ## replace cache, then replace fetcher (while keeping cookiejar) diff --git a/fanficfare/requestable.py b/fanficfare/requestable.py index 7233c238..1e95a807 100644 --- a/fanficfare/requestable.py +++ b/fanficfare/requestable.py @@ -20,6 +20,11 @@ from __future__ import absolute_import import logging logger = logging.getLogger(__name__) +try: + import chardet +except ImportError: + chardet = None + from .configurable import Configurable from .htmlcleanup import reduce_zalgo