From 6ba1e49bfde225e880fa6fa9ea429687ed2eac69 Mon Sep 17 00:00:00 2001 From: Tobias Gruetzmacher Date: Fri, 29 Jun 2018 19:26:17 +0200 Subject: [PATCH] =?UTF-8?q?Kenneth=20Reitz=E2=80=99s=20Code=20Style?= =?UTF-8?q?=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See http://docs.python-requests.org/en/master/dev/contributing/#kenneth-reitz-s-code-style Effectively, this removes "visual" indents. --- dosagelib/cmd.py | 56 ++++++++++++++++++----------------- dosagelib/plugins/d.py | 2 +- dosagelib/plugins/e.py | 4 +-- dosagelib/plugins/s.py | 16 +++++----- tests/modules/check_comics.py | 10 +++---- tests/modules/conftest.py | 12 ++++---- tests/test_util.py | 6 ++-- tox.ini | 2 +- 8 files changed, 55 insertions(+), 53 deletions(-) diff --git a/dosagelib/cmd.py b/dosagelib/cmd.py index b835f0f7b..9e25b65cf 100644 --- a/dosagelib/cmd.py +++ b/dosagelib/cmd.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 @@ -49,54 +49,54 @@ def setup_options(): formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-v', '--verbose', action='count', default=0, - help='provides verbose output, use multiple times for more verbosity') + help='provides verbose output, use multiple times for more verbosity') parser.add_argument('-n', '--numstrips', action='store', type=int, default=0, - help='traverse and retrieve the given number of comic strips; use --all to retrieve all comic strips') + help='traverse and retrieve the given number of comic strips; use --all to retrieve all comic strips') parser.add_argument('-a', '--all', action='store_true', - help='traverse and retrieve all comic strips') + help='traverse and retrieve all comic strips') parser.add_argument('-c', '--continue', action='store_true', dest='cont', - help='traverse and retrieve comic strips until an existing one is found') + help='traverse and retrieve comic strips until an existing one is found') parser.add_argument('-b', '--basepath', action='store', default='Comics', - metavar='PATH', - help='set the path to create invidivual comic directories in, default is Comics') + metavar='PATH', + help='set the path to create invidivual comic directories in, default is Comics') parser.add_argument('--baseurl', action='store', metavar='PATH', - help='the base URL of your comics directory (for RSS, HTML, etc.); this should correspond to --base-path') + help='the base URL of your comics directory (for RSS, HTML, etc.); this should correspond to --base-path') parser.add_argument('-l', '--list', action='store_true', - help='list available comic modules') + help='list available comic modules') parser.add_argument('--singlelist', action='store_true', - help='list available comic modules in a single column list') + help='list available comic modules in a single column list') parser.add_argument('--version', action='store_true', - help='display the version number') + help='display the version number') parser.add_argument('--vote', action='store_true', - help='vote for the selected comics') + help='vote for the selected comics') parser.add_argument('-m', '--modulehelp', action='store_true', - help='display help for comic modules') + help='display help for comic modules') parser.add_argument('-t', '--timestamps', action='store_true', - help='print timestamps for all output at any info level') + help='print timestamps for all output at any info level') parser.add_argument('-o', '--output', action='append', dest='handler', - choices=events.getHandlerNames(), - help='sets output handlers for downloaded comics') + choices=events.getHandlerNames(), + help='sets output handlers for downloaded comics') parser.add_argument('--no-downscale', action='store_false', - dest='allowdownscale', - help='prevent downscaling when using html or rss handler') + dest='allowdownscale', + help='prevent downscaling when using html or rss handler') parser.add_argument('-p', '--parallel', action='store', type=int, default=1, - help='fetch comics in parallel. Specify the number of connections') + help='fetch comics in parallel. Specify the number of connections') parser.add_argument('--adult', action='store_true', - help='confirms that you are old enough to view adult content') + help='confirms that you are old enough to view adult content') parser.add_argument('--allow-multiple', action='store_true', - help='allows multiple instances to run at the same time. Use if you know what you are doing.') + help='allows multiple instances to run at the same time. Use if you know what you are doing.') # used for development testing prev/next matching parser.add_argument('--dry-run', action='store_true', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) # multimatch is only used for development, eg. testing if all comics of a scripted plugin are working parser.add_argument('--multimatch', action='store_true', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) # List all comic modules, even those normally suppressed, because they # are not "real" (moved & removed) parser.add_argument('--list-all', action='store_true', - help=argparse.SUPPRESS) + help=argparse.SUPPRESS) parser.add_argument('comic', nargs='*', - help='comic module name (including case insensitive substrings)') + help='comic module name (including case insensitive substrings)') try: import argcomplete argcomplete.autocomplete(parser) @@ -249,7 +249,8 @@ def do_list(column_list=True, verbose=False, listall=False): """List available comics.""" with out.pager(): out.info(u'Available comic scrapers:') - out.info(u'Comics tagged with [%s] require age confirmation with the --adult option.' % TAG_ADULT) + out.info(u'Comics tagged with [{}] require age confirmation' + ' with the --adult option.'.format(TAG_ADULT)) out.info(u'Non-english comics are tagged with [%s].' % TAG_LANG) scrapers = sorted(scraper.get_scrapers(listall), key=lambda s: s.name.lower()) @@ -260,7 +261,8 @@ def do_list(column_list=True, verbose=False, listall=False): out.info(u'%d supported comics.' % num) if disabled: out.info('') - out.info(u'Some comics are disabled, they are tagged with [%s:REASON], where REASON is one of:' % TAG_DISABLED) + out.info(u'Some comics are disabled, they are tagged with' + ' [{}:REASON], where REASON is one of:'.format(TAG_DISABLED)) for k in disabled: out.info(u' %-10s %s' % (k, disabled[k])) return 0 diff --git a/dosagelib/plugins/d.py b/dosagelib/plugins/d.py index a1ae368da..275e154c6 100644 --- a/dosagelib/plugins/d.py +++ b/dosagelib/plugins/d.py @@ -231,7 +231,7 @@ class DresdenCodak(_ParserScraper): startUrl = url + 'cat/comic/' firstStripUrl = url + '2007/02/08/pom/' imageSearch = '//section[%s]//img[%s]' % ( - xpath_class('entry-content'), xpath_class('aligncenter')) + xpath_class('entry-content'), xpath_class('aligncenter')) prevSearch = '//a[img[contains(@src, "prev")]]' latestSearch = '//a[%s]' % xpath_class('tc-grid-bg-link') starter = indirectStarter diff --git a/dosagelib/plugins/e.py b/dosagelib/plugins/e.py index baa840abc..4bb4fdd8a 100644 --- a/dosagelib/plugins/e.py +++ b/dosagelib/plugins/e.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 @@ -24,7 +24,7 @@ class EarthsongSaga(_ParserScraper): imgmatch = compile(r'images/vol(\d+)/ch(\d+)/(.*)\.\w+$', IGNORECASE).search(image_url) return 'vol%02d_ch%02d_%s' % ( - int(imgmatch.group(1)), int(imgmatch.group(2)), imgmatch.group(3)) + int(imgmatch.group(1)), int(imgmatch.group(2)), imgmatch.group(3)) class EasilyAmused(_WordPressScraper): diff --git a/dosagelib/plugins/s.py b/dosagelib/plugins/s.py index fea5fa367..b6f40c748 100644 --- a/dosagelib/plugins/s.py +++ b/dosagelib/plugins/s.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 @@ -90,13 +90,13 @@ class ScenesFromAMultiverse(_BasicScraper): stripUrl = url + '%s/' firstStripUrl = stripUrl % '2010/06/14/parenthood' imageSearch = ( - compile(tagre("div", "id", "comic") + r"\s*" + - tagre("img", "src", - r'(.*amultiverse.com/wp-content/uploads/\d+/\d+/[^"]+)')), - compile(tagre("div", "id", "comic") + r"\s*" + - tagre("a", "href", r'[^"]*') + - tagre("img", "src", - r'(.*amultiverse.com/wp-content/uploads/\d+/\d+/[^"]+)')), + compile(tagre("div", "id", "comic") + r"\s*" + + tagre("img", "src", + r'(.*amultiverse.com/wp-content/uploads/\d+/\d+/[^"]+)')), + compile(tagre("div", "id", "comic") + r"\s*" + + tagre("a", "href", r'[^"]*') + + tagre("img", "src", + r'(.*amultiverse.com/wp-content/uploads/\d+/\d+/[^"]+)')), ) prevSearch = compile(tagre("a", "href", r'(%scomic/\d+\d+/\d+/\d+/[^"]+)' % rurl, after="prev")) help = 'Index format: yyyy/mm/dd/stripname' diff --git a/tests/modules/check_comics.py b/tests/modules/check_comics.py index e752ff427..50e79fce9 100644 --- a/tests/modules/check_comics.py +++ b/tests/modules/check_comics.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 @@ -85,8 +85,8 @@ def _check_strip(outdir, strip, multipleImagesPerStrip): files.append(fn) assert images, 'failed to find images at %s' % strip.strip_url if not multipleImagesPerStrip: - assert len(images) == 1, 'found more than 1 image at %s: %s' % ( - strip.strip_url, images) + assert len(images) == 1, 'found more than 1 image at {}: {}'.format( + strip.strip_url, images) return files @@ -114,6 +114,6 @@ def _check_stripurl(strip, scraperobj): urlmatch = "^%s$" % urlmatch ro = re.compile(urlmatch) mo = ro.search(strip.strip_url) - err = 'strip URL %r does not match stripUrl pattern %s' % ( - strip.strip_url, urlmatch) + err = 'strip URL {!r} does not match stripUrl pattern {}'.format( + strip.strip_url, urlmatch) assert mo is not None, err diff --git a/tests/modules/conftest.py b/tests/modules/conftest.py index ac9173e77..9a3df9fbf 100644 --- a/tests/modules/conftest.py +++ b/tests/modules/conftest.py @@ -24,12 +24,12 @@ def get_test_scrapers(): # Get limited number of scraper tests on Travis builds to make it # faster testscrapernames = [ - # "classic" _BasicScraper - 'AbstruseGoose', - # complex _ParserScraper - 'GoComics/CalvinAndHobbes', - # _WordPressScraper - 'GrrlPower' + # "classic" _BasicScraper + 'AbstruseGoose', + # complex _ParserScraper + 'GoComics/CalvinAndHobbes', + # _WordPressScraper + 'GrrlPower' ] scraper_pattern = re.compile('^(' + '|'.join(testscrapernames) + ')$') diff --git a/tests/test_util.py b/tests/test_util.py index 8089e3c31..6af0dbd09 100644 --- a/tests/test_util.py +++ b/tests/test_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-2017 Tobias Gruetzmacher +# Copyright (C) 2015-2018 Tobias Gruetzmacher from __future__ import absolute_import, division, print_function @@ -23,8 +23,8 @@ class TestURL(object): def test_normalisation(self): # Test URL normalisation. - assert normaliseURL('http://example.com//bar/baz&baz') == \ - u'http://example.com/bar/baz&baz' + assert (normaliseURL('http://example.com//bar/baz&baz') == + u'http://example.com/bar/baz&baz') class TestRegex(object): diff --git a/tox.ini b/tox.ini index c7b5855f6..95bfdef76 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,7 @@ deps = [flake8] # we aim for 79, but this suppresses warnings for now... max-line-length = 120 -ignore = E121,E126,E241,FI12,FI14,FI15,FI50,FI51,FI53,FI54,FI55 +ignore = E127,E128,E241,FI12,FI14,FI15,FI50,FI51,FI53,FI54,FI55 require-code = True min-version = 2.7