Fix a bunch of flake8 issues

This commit is contained in:
Tobias Gruetzmacher 2019-11-04 00:16:25 +01:00
parent 255fbfa1b4
commit 00d0201c5f
17 changed files with 47 additions and 52 deletions

View file

@ -202,7 +202,6 @@ def vote_comic(scraperobj):
orig_context = out.context orig_context = out.context
out.context = scraperobj.name out.context = scraperobj.name
try: try:
name = scraperobj.name
scraperobj.vote() scraperobj.vote()
out.info(u'Vote submitted.') out.info(u'Vote submitted.')
except Exception as msg: except Exception as msg:

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -215,6 +215,7 @@ class ButImACatPerson(_WordPressScraper):
stripUrl = 'comic/%s/' stripUrl = 'comic/%s/'
firstStripUrl = 'sketches-1' firstStripUrl = 'sketches-1'
class ButtercupFestival(_ParserScraper): class ButtercupFestival(_ParserScraper):
url = 'http://www.buttercupfestival.com/' url = 'http://www.buttercupfestival.com/'
stripUrl = url + '%s.htm' stripUrl = url + '%s.htm'

View file

@ -55,8 +55,10 @@ class FirstWorldProblems(_BasicScraper):
url = 'http://bradcolbow.com/archive/C5/' url = 'http://bradcolbow.com/archive/C5/'
stripUrl = url + '%s/' stripUrl = url + '%s/'
firstStripUrl = stripUrl % 'P10' firstStripUrl = stripUrl % 'P10'
imageSearch = compile(tagre("img", "src", r'(http://(?:fwpcomics\.s3\.amazonaws\.com|s3\.amazonaws\.com/fwpcomics)/s1-[^"]+)')) imageSearch = compile(tagre("img", "src",
prevSearch = compile(tagre("a", "href", r'(http://bradcolbow\.com/archive/C5/[^"]+)', before="prev")) r'(http://(?:fwpcomics\.s3\.amazonaws\.com|s3\.amazonaws\.com/fwpcomics)/s1-[^"]+)'))
prevSearch = compile(tagre("a", "href",
r'(http://bradcolbow\.com/archive/C5/[^"]+)', before="prev"))
multipleImagesPerStrip = True multipleImagesPerStrip = True
help = 'Index format: a letter and a number' help = 'Index format: a letter and a number'
@ -137,6 +139,7 @@ class FredoAndPidjin(_ParserScraper):
starter = indirectStarter starter = indirectStarter
namer = joinPathPartsNamer((0, 1, 2)) namer = joinPathPartsNamer((0, 1, 2))
class Freefall(_BasicScraper): class Freefall(_BasicScraper):
url = 'http://freefall.purrsia.com/default.htm' url = 'http://freefall.purrsia.com/default.htm'
stripUrl = 'http://freefall.purrsia.com/ff%s/fc%s.htm' stripUrl = 'http://freefall.purrsia.com/ff%s/fc%s.htm'

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -10,7 +10,7 @@ from re import compile, escape
from ..scraper import _BasicScraper, _ParserScraper from ..scraper import _BasicScraper, _ParserScraper
from ..helpers import bounceStarter, indirectStarter from ..helpers import bounceStarter, indirectStarter
from ..util import tagre from ..util import tagre
from .common import _ComicControlScraper, _WordPressScraper, _WPNavi from .common import _ComicControlScraper, _WordPressScraper
class Galaxion(_BasicScraper): class Galaxion(_BasicScraper):
@ -189,7 +189,7 @@ class GunnerkriggCourt(_BasicScraper):
imageSearch = compile(tagre("img", "src", r'(/comics/[^"]+)')) imageSearch = compile(tagre("img", "src", r'(/comics/[^"]+)'))
prevSearch = compile( prevSearch = compile(
tagre("a", "href", r'(\?p=\d+)') + tagre("a", "href", r'(\?p=\d+)') +
tagre("img", "src", "/images/prev_a\.jpg")) tagre("img", "src", r'/images/prev_a\.jpg'))
help = 'Index format: number' help = 'Index format: number'

View file

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2016 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from re import compile, escape from re import compile, escape
from ..scraper import _BasicScraper, _ParserScraper from ..scraper import _BasicScraper
from ..util import tagre from ..util import tagre
from ..helpers import bounceStarter, indirectStarter from ..helpers import bounceStarter, indirectStarter
from .common import _ComicControlScraper, _WordPressScraper, _WPNaviIn from .common import _ComicControlScraper, _WordPressScraper, _WPNaviIn

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -179,8 +179,8 @@ class MrLovenstein(_BasicScraper):
firstStripUrl = stripUrl % '1' firstStripUrl = stripUrl % '1'
imageSearch = ( imageSearch = (
# captures rollover comic # captures rollover comic
compile(tagre("div", "class", r'comic_image') + "\s*.*\s*" + compile(tagre("div", "class", r'comic_image') + r'\s*.*\s*' +
tagre("div", "style", r'display: none;') + "\s*.*\s*" + tagre("div", "style", r'display: none;') + r'\s*.*\s' +
tagre("img", "src", r'(/images/comics/[^"]+)')), tagre("img", "src", r'(/images/comics/[^"]+)')),
# captures standard comic # captures standard comic
compile(tagre("img", "src", r'(/images/comics/[^"]+)', compile(tagre("img", "src", r'(/images/comics/[^"]+)',

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -75,7 +75,7 @@ class NichtLustig(_BasicScraper):
url = 'http://www.nichtlustig.de/main.html' url = 'http://www.nichtlustig.de/main.html'
stripUrl = 'http://static.nichtlustig.de/toondb/%s.html' stripUrl = 'http://static.nichtlustig.de/toondb/%s.html'
lang = 'de' lang = 'de'
imageSearch = compile('background-image:url\((http://static\.nichtlustig\.de/comics/full/\d+\.jpg)') imageSearch = compile(r'background-image:url\((http://static\.nichtlustig\.de/comics/full/\d+\.jpg)')
prevSearch = compile(tagre("a", "href", r'(http://static\.nichtlustig\.de/toondb/\d+\.html)')) prevSearch = compile(tagre("a", "href", r'(http://static\.nichtlustig\.de/toondb/\d+\.html)'))
latestSearch = compile(tagre("a", "href", r'([^"]*toondb/\d+\.html)')) latestSearch = compile(tagre("a", "href", r'([^"]*toondb/\d+\.html)'))
help = 'Index format: yymmdd' help = 'Index format: yymmdd'

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2018 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -155,7 +155,7 @@ class SequentialArt(_BasicScraper):
firstStripUrl = stripUrl % '1' firstStripUrl = stripUrl % '1'
imageSearch = compile(tagre("img", "src", r'([^"]+)', before="strip")) imageSearch = compile(tagre("img", "src", r'([^"]+)', before="strip"))
prevSearch = compile(tagre("a", "href", r'(/sequentialart\.php\?s=\d+)') + prevSearch = compile(tagre("a", "href", r'(/sequentialart\.php\?s=\d+)') +
tagre("img", "src", "Nav_BackOne\.gif")) tagre("img", "src", r'Nav_BackOne\.gif'))
help = 'Index format: name' help = 'Index format: name'
@ -193,7 +193,8 @@ class ShermansLagoon(_BasicScraper):
url = 'http://shermanslagoon.com/' url = 'http://shermanslagoon.com/'
stripUrl = url + 'comics/%s' stripUrl = url + 'comics/%s'
firstStripUrl = stripUrl % '/december-29-2003/' firstStripUrl = stripUrl % '/december-29-2003/'
imageSearch = compile(tagre("img", "src", r'(https://safr\.kingfeatures\.com/idn/cnfeed/zone/js/content\.php\?file=.+?)')) imageSearch = compile(tagre("img", "src",
r'(https://safr\.kingfeatures\.com/idn/cnfeed/zone/js/content\.php\?file=.+?)'))
prevSearch = compile(r'id="previouscomic" class="button white"><a href="(%scomics/[a-z0-9-]+/)"' % url) prevSearch = compile(r'id="previouscomic" class="button white"><a href="(%scomics/[a-z0-9-]+/)"' % url)
help = 'Index format: monthname-day-year' help = 'Index format: monthname-day-year'

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -65,7 +65,7 @@ class Weregeek(_BasicScraper):
imageSearch = compile(tagre("img", "src", imageSearch = compile(tagre("img", "src",
r'(%scomics/\d+-\d+-\d+[^"]+)' % rurl)) r'(%scomics/\d+-\d+-\d+[^"]+)' % rurl))
prevSearch = compile(tagre("a", "href", r'((%s)?/?\d+/\d+/\d+/)' % rurl) + prevSearch = compile(tagre("a", "href", r'((%s)?/?\d+/\d+/\d+/)' % rurl) +
'\s*' + tagre('img', 'src', '[^"]*previous_day.gif')) r'\s*' + tagre('img', 'src', '[^"]*previous_day.gif'))
help = 'Index format: yyyy/mm/dd' help = 'Index format: yyyy/mm/dd'

View file

@ -1,11 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2016 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
from ..scraper import _BasicScraper, _ParserScraper from ..scraper import _ParserScraper
from .common import _WordPressScraper from .common import _WordPressScraper

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2016 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -25,9 +25,8 @@ except ImportError:
pycountry = None pycountry = None
from . import loader, configuration, languages from . import loader, configuration, languages
from .util import (get_page, makeSequence, get_system_uid, urlopen, from .util import (get_page, makeSequence, get_system_uid, unescape, tagre,
unescape, tagre, normaliseURL, prettyMatcherList, normaliseURL, prettyMatcherList, requests_session, uniq)
requests_session, uniq)
from .comic import ComicStrip from .comic import ComicStrip
from .output import out from .output import out
from .events import getHandler from .events import getHandler
@ -112,17 +111,6 @@ class Scraper(object):
self.skippedUrls = set() self.skippedUrls = set()
self.hitFirstStripUrl = False self.hitFirstStripUrl = False
def __cmp__(self, other):
"""Compare scraper by name and index list."""
if not isinstance(other, Scraper):
return 1
# first, order by name
d = cmp(self.name, other.name)
if d != 0:
return d
# then by indexes
return cmp(self.indexes, other.indexes)
def __hash__(self): def __hash__(self):
"""Get hash value from name and index list.""" """Get hash value from name and index list."""
return hash((self.name, self.indexes)) return hash((self.name, self.indexes))

View file

@ -84,7 +84,7 @@ def get_system_uid():
def get_nt_system_uid(): def get_nt_system_uid():
"""Get the MachineGuid from r"""Get the MachineGuid from
HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\MachineGuid HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\MachineGuid
""" """
try: try:

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2017 Tobias Gruetzmacher # Copyright (C) 2017-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -47,11 +47,14 @@ def bloomingfaeries():
add(GET, re.compile(r'http://www\.bloomingfaeries\.com/.*\.jpg'), _img(), content_type='image/jpeg') add(GET, re.compile(r'http://www\.bloomingfaeries\.com/.*\.jpg'), _img(), content_type='image/jpeg')
def zenpencils(): def zenpencils():
add(GET, 'https://zenpencils.com/', _content('zp-home')) add(GET, 'https://zenpencils.com/', _content('zp-home'))
add(GET, 'https://zenpencils.com/comic/missing/', _content('zp-223')) add(GET, 'https://zenpencils.com/comic/missing/', _content('zp-223'))
add(GET, 'https://zenpencils.com/comic/lifejacket/', _content('zp-222')) add(GET, 'https://zenpencils.com/comic/lifejacket/', _content('zp-222'))
add(GET, re.compile(r'https://cdn-zenpencils\.netdna-ssl\.com/wp-content/uploads/.*\.jpg'), _img(), content_type='image/jpeg') add(GET, re.compile(r'https://cdn-zenpencils\.netdna-ssl\.com/wp-content/uploads/.*\.jpg'), _img(),
content_type='image/jpeg')
def vote(): def vote():
add(POST, 'https://buildbox.23.gs/count/', '') add(POST, 'https://buildbox.23.gs/count/', '')

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs # Copyright (C) 2004-2008 Tristan Seligmann and Jonathan Jacobs
# Copyright (C) 2012-2014 Bastian Kleineidam # Copyright (C) 2012-2014 Bastian Kleineidam
# Copyright (C) 2015-2017 Tobias Gruetzmacher # Copyright (C) 2015-2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
@ -12,6 +12,7 @@ import dosagelib.cmd
import httpmocks import httpmocks
import json import json
def cmd(*options): def cmd(*options):
"""'Fake' run dosage with given options.""" """'Fake' run dosage with given options."""
return dosagelib.cmd.main(('--allow-multiple',) + options) return dosagelib.cmd.main(('--allow-multiple',) + options)

View file

@ -3,8 +3,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import pytest
import re
from dosagelib.helpers import joinPathPartsNamer from dosagelib.helpers import joinPathPartsNamer

View file

@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2019 Tobias Gruetzmacher
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import pytest
import re
import time import time
from dosagelib.rss import parseFeed from dosagelib.rss import parseFeed
class TestFeed(object): class TestFeed(object):
""" """
Tests for rss.py Tests for rss.py