From fbb3a18c9162a5cd28afcfef712b32050c92a41f Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Wed, 23 May 2018 00:54:40 +0200 Subject: [PATCH] Enable warnings and fix some of them --- .staticsite.py | 5 ++++- dosagelib/plugins/a.py | 7 ++++--- dosagelib/plugins/c.py | 12 ++++++------ dosagelib/plugins/d.py | 3 ++- dosagelib/util.py | 14 ++++++++------ scripts/mklanguages.py | 12 ++++++------ tox.ini | 3 +++ 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/.staticsite.py b/.staticsite.py index e245b5bba..867661d06 100644 --- a/.staticsite.py +++ b/.staticsite.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import absolute_import, division, print_function + SITE_NAME = "dosage" SITE_SUB = "a comic downloader and archiver" SITE_AUTHOR = "Tobias Gruetzmacher" @@ -6,7 +9,7 @@ SITE_LINKS = ( {'name': 'Report Issue', 'icon': 'bug', 'url': 'https://github.com/webcomics/dosage/issues/new'}, ) SITE_ICONS = ( - {'name': 'GitHub', 'icon': 'github', 'url': 'https://github.com/webcomics/dosage/releases/latest'}, + {'name': 'GitHub', 'icon': 'github', 'url': 'https://github.com/webcomics/dosage'}, ) THEME = "doc/.theme" diff --git a/dosagelib/plugins/a.py b/dosagelib/plugins/a.py index f46c9b3f1..4e6888827 100644 --- a/dosagelib/plugins/a.py +++ b/dosagelib/plugins/a.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2017 Tobias Gruetzmacher +# Copyright (C) 2015-2018 Tobias Gruetzmacher from __future__ import absolute_import, division, print_function @@ -42,7 +42,7 @@ class AbsurdNotions(_BasicScraper): imageSearch = compile(tagre('img', 'src', r'(an[^"]+)')) multipleImagesPerStrip = True prevSearch = compile(tagre('a', 'href', r'([^"]+)') + - tagre('img', 'src', 'nprev\.gif')) + tagre('img', 'src', r'nprev\.gif')) help = 'Index format: n (unpadded)' @@ -52,7 +52,7 @@ class AcademyVale(_BasicScraper): firstStripUrl = stripUrl % '001' imageSearch = compile(tagre('img', 'src', r'(avale\d{4}-\d{2}\.gif)')) prevSearch = compile(tagre('a', 'href', r'(avarch[^">]+)', quote="") + - tagre('img', 'src', 'AVNavBack\.gif')) + tagre('img', 'src', r'AVNavBack\.gif')) help = 'Index format: nnn' @@ -240,6 +240,7 @@ class Annyseed(_ParserScraper): return self.stripUrl % '149' return tourl + class AppleGeeks(_BasicScraper): url = 'http://www.applegeeks.com/' stripUrl = url + 'comics/viewcomic.php?issue=%s' diff --git a/dosagelib/plugins/c.py b/dosagelib/plugins/c.py index 5545b641e..b87fecab1 100644 --- a/dosagelib/plugins/c.py +++ b/dosagelib/plugins/c.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2017 Tobias Gruetzmacher +# Copyright (C) 2015-2018 Tobias Gruetzmacher from __future__ import absolute_import, division, print_function from re import compile, escape from ..scraper import _BasicScraper, _ParserScraper -from ..helpers import bounceStarter, indirectStarter +from ..helpers import indirectStarter from ..util import tagre from .common import _TumblrScraper, _WordPressScraper, _WPNavi @@ -177,9 +177,9 @@ class Comedity(_BasicScraper): class CommitStrip(_ParserScraper): baseUrl = 'https://www.commitstrip.com/en/' - url = baseUrl + '?setLocale=1' # ensure the language cookie is set + url = baseUrl + '?setLocale=1' # ensure the language cookie is set stripUrl = baseUrl + '%s/' - firstStripUrl = 'http://www.commitstrip.com/en/2012/02/22/interview/' # non-TLS! + firstStripUrl = 'http://www.commitstrip.com/en/2012/02/22/interview/' # non-TLS! latestSearch = '//section//a' starter = indirectStarter @@ -194,9 +194,9 @@ class CommitStrip(_ParserScraper): class CommitStripFr(CommitStrip): baseUrl = 'https://www.commitstrip.com/fr/' - url = baseUrl + '?setLocale=1' # ensure the language cookie is set + url = baseUrl + '?setLocale=1' # ensure the language cookie is set stripUrl = baseUrl + '%s/' - firstStripUrl = 'http://www.commitstrip.com/fr/2012/02/22/interview/' # non-TLS! + firstStripUrl = 'http://www.commitstrip.com/fr/2012/02/22/interview/' # non-TLS! lang = 'fr' diff --git a/dosagelib/plugins/d.py b/dosagelib/plugins/d.py index eaf253ba0..a1ae368da 100644 --- a/dosagelib/plugins/d.py +++ b/dosagelib/plugins/d.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2017 Tobias Gruetzmacher +# Copyright (C) 2015-2018 Tobias Gruetzmacher from __future__ import absolute_import, division, print_function @@ -72,6 +72,7 @@ class Deathbulge(_BasicScraper): imageSearch = compile(r"(/images/comics/[^\.]+\.jpg)") prevSearch = compile(r'"previous":(\d+),') firstStripUrl = url + '/1' + def getPrevUrl(self, url, data): if data[1] == self.url: data = (data[0], data[1] + '/') diff --git a/dosagelib/util.py b/dosagelib/util.py index 001a52b3a..f4f8a6f28 100644 --- a/dosagelib/util.py +++ b/dosagelib/util.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2016 Tobias Gruetzmacher +# Copyright (C) 2015-2018 Tobias Gruetzmacher from __future__ import absolute_import, division, print_function @@ -19,7 +19,12 @@ import traceback import time import subprocess -from six.moves.html_parser import HTMLParser +try: + import html +except ImportError: + # Python 2.7 + from HTMLParser import HTMLParser + html = HTMLParser() from six.moves import range import six @@ -203,12 +208,9 @@ def prettyMatcherList(things): return "('%s')" % "', '".join(norm) -_htmlparser = HTMLParser() - - def unescape(text): """Replace HTML entities and character references.""" - return _htmlparser.unescape(text) + return html.unescape(text) _nopathquote_chars = "-;/=,~*+()@!" diff --git a/scripts/mklanguages.py b/scripts/mklanguages.py index 258dadcd3..ab707c058 100755 --- a/scripts/mklanguages.py +++ b/scripts/mklanguages.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2017 Tobias Gruetzmacher +# Copyright (C) 2015-2018 Tobias Gruetzmacher '''update languages.py from pycountry''' from __future__ import absolute_import, division, print_function @@ -30,12 +30,12 @@ def main(): def get_used_languages(): - lang = {} + languages = {} for scraperobj in get_scrapers(): - l = scraperobj.lang - if l not in lang: - lang[l] = scraperobj.language() - return lang + lang = scraperobj.lang + if lang not in languages: + languages[lang] = scraperobj.language() + return languages def write_languages(f, l): diff --git a/tox.ini b/tox.ini index 33db75a17..c7b5855f6 100644 --- a/tox.ini +++ b/tox.ini @@ -35,3 +35,6 @@ max-line-length = 120 ignore = E121,E126,E241,FI12,FI14,FI15,FI50,FI51,FI53,FI54,FI55 require-code = True min-version = 2.7 + +[pytest] +filterwarnings = default