From f3b8ebf0beeb5f1276139077840e9249aa897132 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Sat, 28 May 2022 17:52:42 +0200 Subject: [PATCH] Clean up some minor warnings --- dosagelib/cmd.py | 8 ++++---- dosagelib/output.py | 4 ++-- dosagelib/plugins/a.py | 4 ++-- dosagelib/plugins/derideal.py | 1 - dosagelib/plugins/g.py | 4 ++-- dosagelib/plugins/i.py | 5 ++--- dosagelib/plugins/kemonocafe.py | 4 ++-- dosagelib/plugins/mangadex.py | 3 ++- dosagelib/plugins/rickgriffinstudios.py | 5 +++-- dosagelib/plugins/s.py | 6 ++---- dosagelib/plugins/t.py | 5 +++-- dosagelib/plugins/tapastic.py | 3 +-- dosagelib/plugins/w.py | 4 ++-- dosagelib/plugins/y.py | 3 ++- dosagelib/util.py | 18 +++++++++--------- scripts/tapastic.py | 3 +-- tests/modules/conftest.py | 2 +- 17 files changed, 40 insertions(+), 42 deletions(-) diff --git a/dosagelib/cmd.py b/dosagelib/cmd.py index 347c406f3..118d211cd 100644 --- a/dosagelib/cmd.py +++ b/dosagelib/cmd.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2020 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher import argparse import contextlib import os @@ -139,15 +139,15 @@ def display_version(verbose): # display update link text = ('A new version %(version)s of %(app)s is ' 'available at %(url)s.') - attrs = dict(version=version, app=AppName, - url=url, currentversion=__version__) + attrs = {'version': version, 'app': AppName, + 'url': url, 'currentversion': __version__} print(text % attrs) else: if value is None: value = 'invalid update file syntax' text = ('An error occured while checking for an ' 'update of %(app)s: %(error)s.') - attrs = dict(error=value, app=AppName) + attrs = {'error': value, 'app': AppName} print(text % attrs) return 0 diff --git a/dosagelib/output.py b/dosagelib/output.py index f65bbe736..4e14218ee 100644 --- a/dosagelib/output.py +++ b/dosagelib/output.py @@ -103,8 +103,8 @@ class Output(object): def writelines(self, lines, level=0): """Write multiple messages.""" for line in lines: - for line in line.rstrip(u'\n').split(u'\n'): - self.write(line.rstrip(u'\n'), level=level) + for sline in line.rstrip(u'\n').split(u'\n'): + self.write(sline.rstrip(u'\n'), level=level) @property def width(self): diff --git a/dosagelib/plugins/a.py b/dosagelib/plugins/a.py index 8734adb19..1e6c38906 100644 --- a/dosagelib/plugins/a.py +++ b/dosagelib/plugins/a.py @@ -1,14 +1,14 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2021 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from re import compile, escape, MULTILINE from ..util import tagre from ..scraper import _BasicScraper, _ParserScraper from ..helpers import regexNamer, bounceStarter, indirectStarter -from .common import _WordPressScraper, _WPNavi, _WPNaviIn, _WPWebcomic +from .common import _WordPressScraper, _WPNavi, _WPWebcomic class AbstruseGoose(_ParserScraper): diff --git a/dosagelib/plugins/derideal.py b/dosagelib/plugins/derideal.py index 38740f1d9..f0fd9bdbf 100644 --- a/dosagelib/plugins/derideal.py +++ b/dosagelib/plugins/derideal.py @@ -10,7 +10,6 @@ class Derideal(_ParserScraper): imageSearch = '//img[contains(@class, "comic-page")]' prevSearch = '//a[i[contains(@class, "fa-angle-left")]]' latestSearch = '//a[i[contains(@class, "fa-angle-double-right")]]' - starter = indirectStarter def __init__(self, name, sub, first, last=None): if name == 'Derideal': diff --git a/dosagelib/plugins/g.py b/dosagelib/plugins/g.py index d4b72acf3..47fbda7f8 100644 --- a/dosagelib/plugins/g.py +++ b/dosagelib/plugins/g.py @@ -1,12 +1,12 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2021 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring 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 _ComicControlScraper, _WordPressScraper, _WPNavi diff --git a/dosagelib/plugins/i.py b/dosagelib/plugins/i.py index 979536bb8..1cf6a907b 100644 --- a/dosagelib/plugins/i.py +++ b/dosagelib/plugins/i.py @@ -1,14 +1,13 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2020 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from re import compile, escape -from ..helpers import indirectStarter from ..scraper import _BasicScraper, _ParserScraper from ..util import tagre -from .common import _WordPressScraper, _WPNavi, _WPWebcomic +from .common import _WordPressScraper, _WPNavi class IAmArg(_BasicScraper): diff --git a/dosagelib/plugins/kemonocafe.py b/dosagelib/plugins/kemonocafe.py index 38fd68279..8af2094f9 100644 --- a/dosagelib/plugins/kemonocafe.py +++ b/dosagelib/plugins/kemonocafe.py @@ -1,5 +1,5 @@ # SPDX-License-Identifier: MIT -# Copyright (C) 2019-2020 Tobias Gruetzmacher +# Copyright (C) 2019-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from ..scraper import _ParserScraper @@ -25,7 +25,7 @@ class KemonoCafe(_ParserScraper): def namer(self, imageUrl, pageUrl): # Strip date from filenames filename = imageUrl.rsplit('/', 1)[-1] - if not 'ultrarosa' in pageUrl: + if 'ultrarosa' not in pageUrl: if filename[4] == '-' and filename[7] == '-': filename = filename[10:] if filename[0] == '-' or filename[0] == '_': diff --git a/dosagelib/plugins/mangadex.py b/dosagelib/plugins/mangadex.py index ea943edd3..cc45c3c35 100644 --- a/dosagelib/plugins/mangadex.py +++ b/dosagelib/plugins/mangadex.py @@ -86,7 +86,8 @@ class MangaDex(_ParserScraper): def namer(self, imageUrl, pageUrl): # Construct filename from episode number and page index in array - chapterNum = self.chapter['attributes']['chapter'] if self.chapter['attributes']['chapter'] != None else 0 + chapter = self.chapter['attributes']['chapter'] + chapterNum = chapter if chapter is not None else 0 pageNum = self.imageUrls.index(imageUrl) pageExt = imageUrl.rsplit('.')[-1] return '%s-%02d.%s' % (chapterNum, pageNum, pageExt) diff --git a/dosagelib/plugins/rickgriffinstudios.py b/dosagelib/plugins/rickgriffinstudios.py index c57ae6dc9..c7a73f7d0 100644 --- a/dosagelib/plugins/rickgriffinstudios.py +++ b/dosagelib/plugins/rickgriffinstudios.py @@ -49,11 +49,12 @@ class RickGriffinStudios(_WPNaviIn): 'ah-club-2-cover': 'ah-club-1-page-24', 'ah-club-3-cover': 'ah-club-2-page-28', 'ah-club-4-cover': 'ah-club-3-page-22', - 'ah-club-5-cover': 'ah-club-4-page-24' + 'ah-club-5-cover': 'ah-club-4-page-24', }), cls('HayvenCelestia', 'hayven-celestia', 'skinchange-p1'), cls('TheStoryboard', 'the-storyboard', 'the-storyboard-001'), cls('TracesOfThePast', 'in-the-new-age', 'totp-page-1'), cls('TracesOfThePastNSFW', 'in-the-new-age', 'totp-page-1-nsfw', adult=True), - cls('ZootopiaNightTerrors', 'zootopia-night-terrors', 'zootopia-night-terrors-p1', 'zootopia-night-terrors-p7'), + cls('ZootopiaNightTerrors', 'zootopia-night-terrors', + 'zootopia-night-terrors-p1', 'zootopia-night-terrors-p7'), ) diff --git a/dosagelib/plugins/s.py b/dosagelib/plugins/s.py index 782a5edc0..7e5e9f70d 100644 --- a/dosagelib/plugins/s.py +++ b/dosagelib/plugins/s.py @@ -6,12 +6,10 @@ from re import compile, escape, IGNORECASE, sub from os.path import splitext -from requests.exceptions import HTTPError - from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter, bounceStarter, joinPathPartsNamer from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPNaviIn, _WPWebcomic +from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPWebcomic class SabrinaOnline(_BasicScraper): @@ -313,7 +311,7 @@ class SMBC(_ComicControlScraper): url = 'https://www.smbc-comics.com/' stripUrl = url + 'comic/%s' firstStripUrl = stripUrl % '2002-09-05' - imageSearch = ['//img[@id="cc-comic"]', '//div[@id="aftercomic"]/img'] + imageSearch = ('//img[@id="cc-comic"]', '//div[@id="aftercomic"]/img') textSearch = '//img[@id="cc-comic"]/@title' multipleImagesPerStrip = True diff --git a/dosagelib/plugins/t.py b/dosagelib/plugins/t.py index 7e8c1b369..6eb97c3b4 100644 --- a/dosagelib/plugins/t.py +++ b/dosagelib/plugins/t.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2020 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from re import compile, escape, MULTILINE try: @@ -12,7 +12,7 @@ except ImportError: from ..scraper import _BasicScraper, _ParserScraper from ..helpers import indirectStarter from ..util import tagre -from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPNaviIn, _WPWebcomic +from .common import _ComicControlScraper, _WordPressScraper, _WPNavi, _WPWebcomic class TailsAndTactics(_ParserScraper): @@ -53,6 +53,7 @@ class TheBrads(_ParserScraper): multipleImagesPerStrip = True endOfLife = True + class TheChroniclesOfHuxcyn(_WordPressScraper): url = 'https://huxcyn.com/' stripUrl = url + 'comic/%s' diff --git a/dosagelib/plugins/tapastic.py b/dosagelib/plugins/tapastic.py index ae840de56..be08cdd4f 100644 --- a/dosagelib/plugins/tapastic.py +++ b/dosagelib/plugins/tapastic.py @@ -1,8 +1,7 @@ # SPDX-License-Identifier: MIT -# Copyright (C) 2019-2020 Tobias Gruetzmacher +# Copyright (C) 2019-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from ..scraper import _ParserScraper -from ..helpers import indirectStarter class Tapastic(_ParserScraper): diff --git a/dosagelib/plugins/w.py b/dosagelib/plugins/w.py index 63d5657cc..ab1f0f901 100644 --- a/dosagelib/plugins/w.py +++ b/dosagelib/plugins/w.py @@ -1,14 +1,14 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2020 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from re import compile, escape, IGNORECASE from ..scraper import _BasicScraper, _ParserScraper from ..util import tagre from ..helpers import bounceStarter -from .common import _ComicControlScraper, _WPNavi, _WPNaviIn, _WPWebcomic +from .common import _ComicControlScraper, _WPNaviIn, _WPWebcomic class WapsiSquare(_WPNaviIn): diff --git a/dosagelib/plugins/y.py b/dosagelib/plugins/y.py index fa8784677..8a3a2ff15 100644 --- a/dosagelib/plugins/y.py +++ b/dosagelib/plugins/y.py @@ -1,7 +1,7 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2012-2014 Bastian Kleineidam -# Copyright (C) 2015-2020 Tobias Gruetzmacher +# Copyright (C) 2015-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring from .common import _WordPressScraper, _WPWebcomic @@ -16,6 +16,7 @@ class YAFGC(_WordPressScraper): super().__init__(name) self.session.add_throttle('www.yafgc.net', 3.0, 15.5) + class YoshSaga(_WPWebcomic): url = 'https://www.yoshsaga.com/' stripUrl = url + 'comic/%s/' diff --git a/dosagelib/util.py b/dosagelib/util.py index c18c8f8ac..2005f1e76 100644 --- a/dosagelib/util.py +++ b/dosagelib/util.py @@ -118,14 +118,14 @@ def tagre(tag, attribute, value, quote='"', before="", after=""): prefix = r"[^>]*%s[^>]*\s+" % before else: prefix = r"(?:[^>]*\s+)?" - attrs = dict( - tag=case_insensitive_re(tag), - attribute=case_insensitive_re(attribute), - value=value, - quote=quote, - prefix=prefix, - after=after, - ) + attrs = { + 'tag': case_insensitive_re(tag), + 'attribute': case_insensitive_re(attribute), + 'value': value, + 'quote': quote, + 'prefix': prefix, + 'after': after, + } return (r'<\s*%(tag)s\s+%(prefix)s' + r'%(attribute)s\s*=\s*%(quote)s%(value)s%(quote)' + r's[^>]*%(after)s[^>]*>') % attrs @@ -308,7 +308,7 @@ at %(url)s and include at least the information below: Not disclosing some of the information below due to privacy reasons is ok. I will try to help you nonetheless, but you have to give me something I can work with ;) . -""" % dict(app=AppName, url=SupportUrl), file=out) +""" % {'app': AppName, 'url': SupportUrl}, file=out) if etype is None: etype = sys.exc_info()[0] if evalue is None: diff --git a/scripts/tapastic.py b/scripts/tapastic.py index d285c024e..35351c660 100644 --- a/scripts/tapastic.py +++ b/scripts/tapastic.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: MIT -# Copyright (C) 2019-2020 Tobias Gruetzmacher +# Copyright (C) 2019-2022 Tobias Gruetzmacher # Copyright (C) 2019-2020 Daniel Ring """ Script to get a list of Tapastic comics and save the info in a @@ -9,7 +9,6 @@ JSON file for further processing. from urllib.parse import urlsplit, parse_qs from scriptutil import ComicListUpdater -from dosagelib.util import check_robotstxt class TapasticUpdater(ComicListUpdater): diff --git a/tests/modules/conftest.py b/tests/modules/conftest.py index 3973f7b2a..8071a4ab9 100644 --- a/tests/modules/conftest.py +++ b/tests/modules/conftest.py @@ -52,6 +52,6 @@ class LoadModScheduling(LoadScopeScheduling): return mod + "::" + test.split("/", 1)[0] -@pytest.mark.trylast +@pytest.mark.trylast() def pytest_xdist_make_scheduler(config, log): return LoadModScheduling(config, log)