jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Made multiple files pep257 compatible ......................................................................
[IMPROV] Made multiple files pep257 compatible
Those files usually only needed a few changes (<= 3) to be compatible. Made some epydoc compatible.
There was also a small error in the description of the rotating file handler. The condition for one of the options was identical for a completely different procedure.
Change-Id: I60417587c65711974f5a3ef3096cf6faa005cb2e --- M pywikibot/bot.py M pywikibot/botirc.py M pywikibot/compat/query.py M pywikibot/data/__init__.py M pywikibot/i18n.py M pywikibot/interwiki_graph.py M pywikibot/page.py M pywikibot/plural.py M pywikibot/tools.py M pywikibot/userinterfaces/terminal_interface.py M pywikibot/userinterfaces/transliteration.py M pywikibot/version.py M tox.ini 13 files changed, 82 insertions(+), 54 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py index 614814f..d588612 100644 --- a/pywikibot/bot.py +++ b/pywikibot/bot.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""User-interface related functions for building bots""" +"""User-interface related functions for building bots.""" # # (C) Pywikibot team, 2008-2013 # @@ -49,6 +49,8 @@ # Logging module configuration class RotatingFileHandler(logging.handlers.RotatingFileHandler):
+ """Modified RotatingFileHandler supporting unlimited amount of backups.""" + def doRollover(self): """ Modified naming system for logging files. @@ -63,7 +65,7 @@ when it gets filled up, it is closed and renamed to "app.1.log", and if files "app.1.log", "app.2.log" etc. already exist, then they are renamed to "app.2.log", "app.3.log" etc. respectively. - If backupCount is >= 1 do not rotate but create new numbered filenames. + If backupCount is == -1 do not rotate but create new numbered filenames. The newest file has the highest number except some older numbered files where deleted and the bot was restarted. In this case the ordering starts from the lowest available (unused) number. @@ -946,6 +948,8 @@
""" Generic Wikidata Bot to be subclassed. + + Source claims (P143) can be created for specific sites. """
def cacheSources(self): diff --git a/pywikibot/botirc.py b/pywikibot/botirc.py index 6ec058e..11a27a1 100644 --- a/pywikibot/botirc.py +++ b/pywikibot/botirc.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -User-interface related functions for building bots +User-interface related functions for building bots.
Note: the script requires the Python IRC library http://python-irclib.sourceforge.net/ @@ -30,7 +30,7 @@ class IRCBot(pywikibot.Bot, SingleServerIRCBot):
""" - Generic IRC Bot to be subclassed + A generic IRC Bot to be subclassed.
A Bot that displays the ordinal number of the new articles being created visible on the Recent Changes list. The Bot doesn't make any edits, no diff --git a/pywikibot/compat/query.py b/pywikibot/compat/query.py index c203e54..bd9aa77 100644 --- a/pywikibot/compat/query.py +++ b/pywikibot/compat/query.py @@ -1,3 +1,16 @@ +# -*- coding: utf-8 -*- +""" +WARNING: THIS MODULE EXISTS SOLELY TO PROVIDE BACKWARDS-COMPATIBILITY. + +Do not use in new scripts; use the source to find the appropriate +function/method instead. + +""" +# +# (C) Pywikibot team, 2008 +# +# Distributed under the terms of the MIT license. +# import pywikibot from pywikibot.data import api from pywikibot.tools import deprecated, deprecate_arg diff --git a/pywikibot/data/__init__.py b/pywikibot/data/__init__.py index 5b530da..81fe96f 100644 --- a/pywikibot/data/__init__.py +++ b/pywikibot/data/__init__.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- -""" -The "data" module provides several physical layers of data access to the wiki. -""" +"""Module providing several layers of data access to the wiki.""" # # (C) Pywikibot team, 2007-2014 # diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py index 52ce1c9..e10ccbf 100644 --- a/pywikibot/i18n.py +++ b/pywikibot/i18n.py @@ -348,14 +348,15 @@
def twtranslate(code, twtitle, parameters=None): - """Translate a message. + """ + Translate a message.
- @param code The language code - @param twtitle The TranslateWiki string title, in <package>-<key> format - @param parameters For passing parameters. + The translations are retrieved from i18n.<package>, based on the callers + import table.
- The translations are retrieved from i18n.<package>, based on the callers - import table. + @param code: The language code + @param twtitle: The TranslateWiki string title, in <package>-<key> format + @param parameters: For passing parameters. """ package = twtitle.split("-")[0] transdict = getattr(__import__(messages_package_name, fromlist=[package]), package).msg @@ -402,11 +403,11 @@
# Maybe this function should be merged with twtranslate def twntranslate(code, twtitle, parameters=None): - """Translate a message with plural support. + r"""Translate a message with plural support.
- @param code The language code - @param twtitle The TranslateWiki string title, in <package>-<key> format - @param parameters For passing (plural) parameters. + @param code: The language code + @param twtitle: The TranslateWiki string title, in <package>-<key> format + @param parameters: For passing (plural) parameters.
Support is implemented like in MediaWiki extension. If the TranslateWiki message contains a plural tag inside which looks like @@ -452,7 +453,6 @@
The translations are retrieved from i18n.<package>, based on the callers import table. - """ # If a site is given instead of a code, use its language if hasattr(code, 'code'): @@ -483,9 +483,8 @@
No code fallback is made.
- @param code The language code - @param twtitle The TranslateWiki string title, in <package>-<key> format - + @param code: The language code + @param twtitle: The TranslateWiki string title, in <package>-<key> format """ package = twtitle.split("-")[0] transdict = getattr(__import__("i18n", fromlist=[package]), package).msg @@ -496,20 +495,17 @@
def input(twtitle, parameters=None, password=False): - """ Ask the user a question, return the user's answer. + """ + Ask the user a question, return the user's answer.
- @param twtitle The TranslateWiki string title, in <package>-<key> format - @param parameters For passing parameters. In the future, this will - be used for plural support. - @param password Hides the user's input (for password entry) - Returns a unicode string + The prompt message is retrieved via L{twtranslate} and either uses the + config variable 'userinterface_lang' or the default locale as the language + code.
- The translations are retrieved from i18n.<package>, based on the callers - import table. - Translation code should be set by in the user_config.py like - userinterface_lang = 'de' - default is os locale setting - + @param twtitle: The TranslateWiki string title, in <package>-<key> format + @param parameters: The values which will be applied to the translated text + @param password: Hides the user's input (for password entry) + @rtype: unicode string """ code = config.userinterface_lang or \ locale.getdefaultlocale()[0].split('_')[0] diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py index 68ec8bd..d1d4754 100644 --- a/pywikibot/interwiki_graph.py +++ b/pywikibot/interwiki_graph.py @@ -1,4 +1,4 @@ -""" Module with the graphviz drawing calls """ +""" Module with the Graphviz drawing calls. """ # # (C) Pywikibot team, 2006-2010 # @@ -20,7 +20,7 @@
class GraphImpossible(Exception):
- "Drawing a graph is not possible on your system." + """Drawing a graph is not possible on your system."""
class GraphSavingThread(threading.Thread): diff --git a/pywikibot/page.py b/pywikibot/page.py index b08ebd1..d9287f5 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -3952,7 +3952,6 @@ pywikibot.Error is raised.
""" - ns_id = self.namespace ns = self.site.namespaces()[ns_id] ns_names = list(self.site.namespaces()[ns_id]) diff --git a/pywikibot/plural.py b/pywikibot/plural.py index 2b02046..02a50e4 100644 --- a/pywikibot/plural.py +++ b/pywikibot/plural.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +"""Module containing plural rules of various languages.""" # # (C) xqt, 2011 # (C) Pywikibot team, 2011 diff --git a/pywikibot/tools.py b/pywikibot/tools.py index c90790e..1cbe087 100644 --- a/pywikibot/tools.py +++ b/pywikibot/tools.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -"""Miscellaneous helper functions (not wiki-dependent)""" +"""Miscellaneous helper functions (not wiki-dependent).""" # # (C) Pywikibot team, 2008 # @@ -47,6 +47,9 @@
# From http://python3porting.com/preparing.html class ComparableMixin(object): + + """Mixin class to allow comparing to other objects of this class.""" + def _compare(self, other, method): try: return method(self._cmpkey(), other._cmpkey()) @@ -204,6 +207,7 @@ ...
""" + def __init__(self, limit=128, *args): self.limit = limit list.__init__(self, *args) diff --git a/pywikibot/userinterfaces/terminal_interface.py b/pywikibot/userinterfaces/terminal_interface.py index a58b3f5..b0e2743 100644 --- a/pywikibot/userinterfaces/terminal_interface.py +++ b/pywikibot/userinterfaces/terminal_interface.py @@ -1,4 +1,9 @@ # -*- coding: utf-8 -*- +""" +Platform independent terminal interface module. + +It imports the appropriate operating system specific implementation. +""" # # (C) Pywikibot team, 2003-2014 # diff --git a/pywikibot/userinterfaces/transliteration.py b/pywikibot/userinterfaces/transliteration.py index 2cbae3a..1d8e217 100644 --- a/pywikibot/userinterfaces/transliteration.py +++ b/pywikibot/userinterfaces/transliteration.py @@ -1,8 +1,12 @@ # -*- coding: utf-8 -*- +"""Module to transliterate text.""" __version__ = '$Id$'
class transliterator(object): + + """Class to transliterating text.""" + def __init__(self, encoding): self.trans = {} for char in u"ÀÁÂẦẤẪẨẬÃĀĂẰẮẴẶẲȦǠẠḀȂĄǍẢ": diff --git a/pywikibot/version.py b/pywikibot/version.py index cbb70a2..7ca8a0c 100644 --- a/pywikibot/version.py +++ b/pywikibot/version.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -""" Module to determine the pywikibot version (tag, revision and date) """ +""" Module to determine the pywikibot version (tag, revision and date). """ # # (C) Merlijn 'valhallasw' van Deen, 2007-2014 # (C) xqt, 2010-2014 @@ -95,16 +95,12 @@ def svn_rev_info(path): """Fetch information about the current revision of an Subversion checkout.
- Returns three strings: - * 'tag': name for the repository - * 'rev': current Subversion revision identifier - * 'date': date of current revision - @param path: directory of the Subversion checkout - @return: tag (name for the repository), - rev (current Subversion revision identifier), - date (date of current revision) - @return: C{tuple} of 3 C{str} + @return: + - tag (name for the repository), + - rev (current Subversion revision identifier), + - date (date of current revision), + @rtype: C{tuple} of 3 C{str} """ _program_dir = path entries = open(os.path.join(_program_dir, '.svn/entries')) @@ -169,11 +165,12 @@ """Get version info for a Subversion checkout.
@param path: directory of the Subversion checkout - @return: tag (name for the repository), - rev (current Subversion revision identifier), - date (date of current revision), - hash (git hash for the Subversion revision) - @return: C{tuple} of 4 C{str} + @return: + - tag (name for the repository), + - rev (current Subversion revision identifier), + - date (date of current revision), + - hash (git hash for the Subversion revision) + @rtype: C{tuple} of 4 C{str} """ _program_dir = path or _get_program_dir() tag, rev, date = svn_rev_info(_program_dir) diff --git a/tox.ini b/tox.ini index ddecf62..a3ce817 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ deps = flake8
[testenv:flake8-docstrings] -commands = flake8 {posargs} --jobs=1 --ignore=D102,D103 +commands = flake8 {posargs} --jobs=1 --ignore=D102,D103,E122,E127,E241,E265 deps = flake8-docstrings # Note: flake8 is run here with --jobs=1 to disable multiprocessing which stall # the run with flake8-docstrings / pep257. @@ -28,7 +28,14 @@ commands = flake8 --jobs=1 --ignore=D102,D103,E122,E127,E241,E265 \ ./pywikibot/echo.py ./pywikibot/config2.py ./pywikibot/weblib.py \ ./pywikibot/fixes.py ./pywikibot/editor.py ./pywikibot/comms/http.py \ - ./pywikibot/compat/userlib.py ./pywikibot/compat/catlib.py + ./pywikibot/userinterfaces/transliteration.py \ + ./pywikibot/userinterfaces/terminal_interface.py \ + ./pywikibot/page.py ./pywikibot/version.py ./pywikibot/plural.py \ + ./pywikibot/botirc.py ./pywikibot/interwiki_graph.py ./pywikibot/tools.py \ + ./pywikibot/bot.py \ + ./pywikibot/data/__init__.py \ + ./pywikibot/compat/userlib.py ./pywikibot/compat/catlib.py \ + ./pywikibot/compat/query.py deps = flake8-docstrings
[testenv:nose]
pywikibot-commits@lists.wikimedia.org