diff --git a/fanficfare/cli.py b/fanficfare/cli.py index cc0c3c9f..0cc97d33 100644 --- a/fanficfare/cli.py +++ b/fanficfare/cli.py @@ -15,6 +15,8 @@ # limitations under the License. # +from __future__ import absolute_import +from __future__ import print_function from optparse import OptionParser, SUPPRESS_HELP from os.path import expanduser, join, dirname from os import access, R_OK @@ -264,7 +266,7 @@ def main(argv=None, options.cookiejar = cl.LWPCookieJar() options.cookiejar.load('global_cookies') except Exception as e: - print("didn't load global_cache %s"%e) + print("Didn't load global_cache %s"%e) if not list_only: if len(urls) < 1: diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 7d4d43c8..e89835b0 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -21,7 +21,7 @@ import codecs # py2 vs py3 transition import six -import six.moves.configparser as ConfigParser +from six.moves import configparser from six.moves.configparser import DEFAULTSECT, MissingSectionHeaderError, ParsingError from six.moves import urllib from six.moves.urllib.request import (build_opener, HTTPCookieProcessor) @@ -495,11 +495,11 @@ def make_generate_cover_settings(param): return vlist -class Configuration(ConfigParser.SafeConfigParser): +class Configuration(configparser.SafeConfigParser): def __init__(self, sections, fileform, lightweight=False): site = sections[-1] # first section is site DN. - ConfigParser.SafeConfigParser.__init__(self) + configparser.SafeConfigParser.__init__(self) self.lightweight = lightweight self.use_pagecache = False # default to false for old adapters. @@ -650,7 +650,7 @@ class Configuration(ConfigParser.SafeConfigParser): val = False #print("getConfig(%s)=[%s]%s" % (key,section,val)) break - except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e: + except (configparser.NoOptionError, configparser.NoSectionError) as e: pass for section in sections[::-1]: @@ -658,7 +658,7 @@ class Configuration(ConfigParser.SafeConfigParser): try: val = val + self.get(section,"add_to_"+key) #print("getConfig(add_to_%s)=[%s]%s" % (key,section,val)) - except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e: + except (configparser.NoOptionError, configparser.NoSectionError) as e: pass return val diff --git a/fanficfare/htmlcleanup.py b/fanficfare/htmlcleanup.py index 6ae709df..3d1bc41b 100644 --- a/fanficfare/htmlcleanup.py +++ b/fanficfare/htmlcleanup.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2011 Fanficdownloader team, 2015 FanFicFare team +# Copyright 2011 Fanficdownloader team, 2018 FanFicFare team # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ def removeEntities(text, space_only=False): return unicode(text) try: - t = text #.decode('utf-8') + t = text except (UnicodeEncodeError,UnicodeDecodeError) as e: try: t = text.encode ('ascii', 'xmlcharrefreplace')