jenkins-bot has submitted this change and it was merged. Change subject: [tox] pep8/257 and other tests ......................................................................
[tox] pep8/257 and other tests cleanup several scripts. Change-Id: Ib3c245f7de4ad06591bd3afa34e02a0d690dcf61 --- M afd-notice.py M checkvotes.py M imagereview.py M tests/imagereview_tests.py M tests/vandalism_tests.py M tox.ini M vandalism.py 7 files changed, 84 insertions(+), 44 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/afd-notice.py b/afd-notice.py index 4740dc2..5acdf78 100644 --- a/afd-notice.py +++ b/afd-notice.py @@ -18,14 +18,14 @@ # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __version__ = '$Id: b8b58400a557856fe9df819978e4b30036e4a643 $' # -from collections import Counter import pickle import time +from collections import Counter import pywikibot from pywikibot import config, pagegenerators, textlib @@ -270,6 +270,14 @@ def main(): + """ + Process command line arguments and invoke bot. + + If args is an empty list, sys.argv is used. + + @param args: command line arguments + @type args: list of unicode + """ options = {} for arg in pywikibot.handle_args(): options[arg[1:]] = True diff --git a/checkvotes.py b/checkvotes.py index 06ec3d7..b6f9eb2 100644 --- a/checkvotes.py +++ b/checkvotes.py @@ -16,7 +16,7 @@ -sg Check arbcom election """ -from __future__ import print_function, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __version__ = '$Id: b7d0f7af1cfce7db63fe73ddf71d24191b41d14a $' # @@ -182,6 +182,9 @@ class CheckBot(object): + + """CheckBot to check votings.""" + # Edit summary message that should be used. msg = { 'de': 'Bot: Stimmberechtigung geprüft', @@ -190,7 +193,9 @@ def __init__(self, generator, template, dry, always, blockinfo): """ - Constructor. Parameters: + Constructor. + + Parameters: * generator - The page generator that determines on which pages to work on. * dry - If True, doesn't do any real changes, but only shows diff --git a/imagereview.py b/imagereview.py index 38af78d..b34eac8 100644 --- a/imagereview.py +++ b/imagereview.py @@ -3,6 +3,7 @@ # """ This bot script is developed for the image review processing on de-wiki. + See https://de.wikipedia.org/wiki/Wikipedia:D%C3%9CP for it This script is run by [[de:user:xqt]]. @@ -24,7 +25,7 @@ -total:<number> Only check the given number of files """ -from __future__ import print_function, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals # # (C) xqt, 2012-2016 # @@ -308,9 +309,7 @@ raise NotImplementedError('Invalid option') def setOptions(self, **kwargs): - """ - Sets the instance options - """ + """Set the instance options.""" # contains the options overriden from defaults self.options = {} @@ -327,6 +326,7 @@ def getOption(self, option): """ Get the current value of an option. + @param option: key defined in Bot.availableOptions """ try: @@ -365,9 +365,7 @@ yield page def save(self, page, newText, summary=None): - """ - Saves the page to the wiki, if the user accepts the changes made. - """ + """Save the page to the wiki, if the user accepts the changes made.""" done = False try: oldtext = page.get() @@ -409,12 +407,14 @@ return done def inform_user(self, user, data): - """ data = [title(asLink=True), + """ + Inform user. + + data = [title(asLink=True), [user, timestamp], DUP_Image{}, <leer|reasons>, - ] - + ] """ # verstorbene ignoreUser = set() @@ -580,13 +580,13 @@ summary += u', Vorlage:Information ergänzt' inline += """ {{Information -|Beschreibung = -|Quelle = -|Urheber = -|Datum = -|Genehmigung = -|Andere Versionen = -|Anmerkungen = +|Beschreibung = +|Quelle = +|Urheber = +|Datum = +|Genehmigung = +|Andere Versionen = +|Anmerkungen = }} """ # noqa firstTmpl = tmpl.pop(0) diff --git a/tests/imagereview_tests.py b/tests/imagereview_tests.py index 014a276..8290071 100644 --- a/tests/imagereview_tests.py +++ b/tests/imagereview_tests.py @@ -5,7 +5,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __version__ = '$Id$' @@ -14,16 +14,16 @@ import sys import unittest -import pywikibot -from pywikibot import config, Timestamp -from pywikibot.tools import StringTypes - currentdir = os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0, parentdir) -import imagereview +import imagereview # noqa +import pywikibot + +from pywikibot import Timestamp, config +from pywikibot.tools import StringTypes class TestMessages(unittest.TestCase): @@ -79,7 +79,7 @@ self.assertEqual(self.image._contents, self.image.text) def test_empty_instance(self): - """Test instance variables""" + """Test instance variables.""" self.image = imagereview.DUP_Image(self.site, 'Sample.jpg') self.assertIsNone(self.image._contents) self.assertIsNone(self.image._editTime) diff --git a/tests/vandalism_tests.py b/tests/vandalism_tests.py index 32ae84a..fc49eeb 100644 --- a/tests/vandalism_tests.py +++ b/tests/vandalism_tests.py @@ -5,7 +5,7 @@ # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __version__ = '$Id$' @@ -29,7 +29,7 @@ dry = True def test_get_accuser(self): - """Test getAccUser method""" + """Test getAccUser method.""" self.assertEqual(getAccuser(''), ('', '')) self.assertEqual(getAccuser( 'foo bar ([[Benutzer:xqt|xqbot]]) ' diff --git a/tox.ini b/tox.ini index 6db3873..9a78977 100644 --- a/tox.ini +++ b/tox.ini @@ -19,16 +19,38 @@ commands = flake8 {posargs} basepython = python2.7 deps = flake8 + git+https://github.com/pyflakes/pyflakes.git + flake8-docstrings<0.2.2 + flake8-coding + flake8-future-import + flake8-string-format + flake8-import-order [testenv:flake8-py3] commands = flake8 {posargs} basepython = python3 deps = flake8 + git+https://github.com/pyflakes/pyflakes.git + flake8-docstrings<0.2.2 [flake8] +; D102 Missing docstring +; D103 Missing docstring +; D211: No blank lines allowed before class docstring ; E115 expected an indented block (comment) ; E266 too many leading '#' for block comment ; E402 module level import not at top of file (T87409) -ignore = E115,E266,E402 -exclude = .tox,.git,./*.egg,ez_setup.py,build +; FI10,FI12,FI13,FI15: __future__ import "division", "with_statement", "print_function" and "generator_stop" missing +; FI5: __future__ import "x" present +; P102,P103: string does contain unindexed parameters; see I36355923 +ignore = D102,D103,D211,E115,E266,E402,FI10,FI12,FI15,FI5,P102 +exclude = .tox,.git,./*.egg,ez_setup.py,build,*__init__* max_line_length = 289 + +[pep8] +ignore = E402 +exclude = .tox,.git,./*.egg,ez_setup.py,build +max_line_length = 100 + +[pep257] +ignore = D105,D211 diff --git a/vandalism.py b/vandalism.py index 0264be7..a094ac0 100644 --- a/vandalism.py +++ b/vandalism.py @@ -1,25 +1,25 @@ #!/usr/bin/python # -*- coding: utf-8 -*- """ - Wikipedia-pybot-framework is needed! +@note: Pywikibot framework is needed. - These command line parameters can be used to specify how to work: - ... +These command line parameters can be used to specify how to work: +... - authors: Euku, xqt +authors: Euku, xqt """ # -from __future__ import unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __version__ = '$Id: 7582c97b81fc2ef90dee82bfe9cfae8282fbd3db $' # import re -from time import sleep from datetime import timedelta +from time import sleep import pywikibot -from pywikibot import config, textlib, Timestamp +from pywikibot import Timestamp, config, textlib vmHeadlineRegEx = (r"(==\ *?\[*?(?:[Bb]enutzer(?:in)?:\s?|[Uu]ser:|" r"Spezial\:Beiträge\/|Special:Contributions\/)?" @@ -59,7 +59,9 @@ def divideIntoSlices(rawText): """ - analyze the whole text to get the intro, the headlines and the + Anlalyze text. + + Analyze the whole text to get the intro, the headlines and the corresponding bodies """ textLines = rawText.split("\n") @@ -100,7 +102,7 @@ def getAccuser(rawText): - """ return a username and a timestamp. """ + """Return a username and a timestamp.""" sigRegEx = ("\[\[(?:[Bb]enutzer(?:in)?(?:[ _]Diskussion)?\:|" "[Uu]ser(?:[ _]talk)?\:|Spezial\:Beiträge\/|" "Special:Contributions\/)(?P<username>[^|\]]+)\|.*?\]\].{1,30}") @@ -142,7 +144,7 @@ useredits = 25 # min edits for experienced users def __init__(self, **kwargs): - """ Only accept options defined in availableOptions """ + """Only accept options defined in availableOptions.""" self.availableOptions.update({ 'force': False, 'projectpage': 'VM' @@ -169,7 +171,7 @@ self.nexttimestamp = "20150201123456" def optOutUsersToCheck(self, pageName): - """ read opt-in list. """ + """Read opt-in list.""" result = set() ignorePage = pywikibot.Page(self.site, pageName) for page in ignorePage.linkedPages(): @@ -180,7 +182,8 @@ def userIsExperienced(self, username): """ - is this user experienced? + Check whether is this user is experienced. + user is experienced if edits >= 50 changed to 25 // 20150309 @@ -225,6 +228,8 @@ def loadBlockedUsers(self): """ + Load blocked users. + return: [(blockedusername, byadmin, timestamp, blocklength, reason)] """ -- To view, visit https://gerrit.wikimedia.org/r/282482 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib3c245f7de4ad06591bd3afa34e02a0d690dcf61 Gerrit-PatchSet: 11 Gerrit-Project: pywikibot/bots/xqbot Gerrit-Branch: master Gerrit-Owner: Xqt <i...@gno.de> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits