jenkins-bot has submitted this change and it was merged.
Change subject: PEP257 on pywikibot folder part III
......................................................................
PEP257 on pywikibot folder part III
files: logentries, login, page, pagegenerators, textlib, throttle.
tools, version, xmlreader
Checked by hand and added some suggestions based on this change:
I910fdd7ce36752fa44b9a6654d7b8509e5020dee
Change-Id: Ic65452262d16ba2ec83633125ce1e3145a6f3aef
---
M pywikibot/logentries.py
M pywikibot/login.py
M pywikibot/page.py
M pywikibot/pagegenerators.py
M pywikibot/textlib.py
M pywikibot/throttle.py
M pywikibot/version.py
M pywikibot/xmlreader.py
8 files changed, 58 insertions(+), 55 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 6cd2cc6..dfcb883 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Objects representing Mediawiki log entries
-"""
+"""Objects representing Mediawiki log entries."""
#
# (C) Pywikibot team, 2007-2013
#
@@ -23,6 +21,7 @@
It also logs debugging information when a key is missing.
"""
+
def __missing__(self, key):
pywikibot.debug(u"API log entry received:\n" + repr(self),
_logger)
@@ -127,7 +126,7 @@
"""
Return a list of (str) flags associated with the block entry.
- Raises an Error if the entry is an unblocking log entry
+ It raises an Error if the entry is an unblocking log entry.
"""
if hasattr(self, '_flags'):
return self._flags
@@ -138,8 +137,8 @@
"""
Return a datetime.timedelta representing the block duration.
- It returns None if block is indefinite.
- Raises an Error if the entry is an unblocking log entry
+ @return: datetime.timedelta, or None if block is indefinite.
+ @raises Error: the entry is an unblocking log entry.
"""
if hasattr(self, '_duration'):
return self._duration
@@ -154,7 +153,7 @@
"""
Return a Timestamp representing the block expiry date.
- Raises an Error if the entry is an unblocking log entry
+ @raises Error: the entry is an unblocking log entry.
"""
if hasattr(self, '_expiry'):
return self._expiry
@@ -185,7 +184,7 @@
return self.data['move']['new_ns']
def new_title(self):
- """Page object of the new title"""
+ """Return page object of the new title."""
if not hasattr(self, '_new_title'):
self._new_title = pywikibot.Page(pywikibot.Link(self.data['move']['new_title']))
return self._new_title
@@ -217,7 +216,7 @@
class LogEntryFactory(object):
"""
- LogEntry Factory
+ LogEntry Factory.
Only available method is create()
"""
@@ -257,7 +256,7 @@
@param logdata: <item> returned by the api
@type logdata: dict
- @return LogEntry object representing logdata
+ @return: LogEntry object representing logdata
"""
return self._creator(logdata)
@@ -266,7 +265,8 @@
"""
Return the class corresponding to the @logtype string parameter.
- Returns LogEntry if logtype is unknown or not supported
+ @return: specified subclass of LogEntry, or LogEntry
+ @rtype: class
"""
try:
return LogEntryFactory._logtypes[logtype]
@@ -276,6 +276,10 @@
def _createFromData(self, logdata):
"""
Check for logtype from data, and creates the correct LogEntry.
+
+ @param logdata: log entry data
+ @type logdata: dict
+ @rtype: LogEntry
"""
try:
logtype = logdata['type']
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 1445d4b..feece17 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -1,8 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-"""
-Library to log the robot in to a wiki account.
-"""
+"""Library to log the bot in to a wiki account."""
#
# (C) Rob W.W. Hooft, 2003
# (C) Pywikibot team, 2003-2012
diff --git a/pywikibot/page.py b/pywikibot/page.py
index d9287f5..3d5dfe3 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -141,7 +141,8 @@
def namespace(self):
"""Return the number of the namespace of the page.
- @return: int
+ @return: namespace of the page
+ @rtype: int
"""
return self._link.namespace
@@ -394,7 +395,8 @@
def text(self):
"""Return the current (edited) wikitext, loading it if necessary.
- @return: unicode
+ @return: text of the page
+ @rtype: unicode
"""
if not hasattr(self, '_text') or self._text is None:
try:
@@ -3567,7 +3569,8 @@
"""
Format the target into the proper JSON value that Wikibase wants.
- @return: dict
+ @return: JSON value
+ @rtype: dict
"""
if self.type == 'wikibase-item':
value = {'entity-type': 'item',
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 91c973b..0ba02b4 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -215,6 +215,7 @@
This factory is responsible for processing command line arguments
that are used by many scripts and that determine which pages to work on.
"""
+
def __init__(self, site=None):
self.gens = []
self.namespaces = []
@@ -230,7 +231,6 @@
Only call this after all arguments have been parsed.
"""
-
if gen:
self.gens.insert(0, gen)
@@ -889,7 +889,7 @@
@classmethod
def __precompile(cls, regex, flag):
- """ precompile the regex list if needed. """
+ """Precompile the regex list if needed."""
# Enable multiple regexes
if not isinstance(regex, list):
regex = [regex]
@@ -906,6 +906,7 @@
""" Yield pages from another generator whose title matches regex.
Uses regex option re.IGNORECASE depending on the quantifier parameter.
+
If ignore_namespace is False, the whole page title is compared.
NOTE: if you want to check for a match at the beginning of the title,
you have to start the regex with "^"
@@ -1050,7 +1051,6 @@
@deprecate_arg("lookahead", None)
def PreloadingGenerator(generator, step=50):
"""Yield preloaded pages taken from another generator."""
-
# pages may be on more than one site, for example if an interwiki
# generator is used, so use a separate preloader for each site
sites = {}
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 0efe511..10088ac 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -335,8 +335,7 @@
"""
Return True if text[index] is disabled, e.g. by a comment or by nowiki tags.
- For the tags parameter, see removeDisabledParts() above.
-
+ For the tags parameter, see L{removeDisabledParts}.
"""
# Find a marker that is not already in the text.
marker = findmarker(text)
@@ -508,7 +507,6 @@
'new' should be a dict with the Site objects as keys, and Page or Link
objects as values (i.e., just like the dict returned by getLanguageLinks
function).
-
"""
# Find a marker that is not already in the text.
marker = findmarker(oldtext)
@@ -596,7 +594,6 @@
Return a unicode string that is formatted for inclusion in insite
(defaulting to the current site).
-
"""
if insite is None:
insite = pywikibot.Site()
@@ -654,8 +651,7 @@
"""Return a list of category links found in text.
@return: all category links found
- @returntype: list of Category objects
-
+ @rtype: list of Category objects
"""
result = []
if site is None:
@@ -688,7 +684,6 @@
Put the string marker after the last replacement (at the end of the text
if there is no replacement).
-
"""
# This regular expression will find every link that is possibly an
# interwiki link, plus trailing whitespace. The language code is grouped.
@@ -728,9 +723,14 @@
def replaceCategoryInPlace(oldtext, oldcat, newcat, site=None):
- """Replace the category oldcat with the category newcat.
+ """
+ Replace old category with new one and return the modified text.
+ @param oldtext: Content of the old category
+ @param oldcat: pywikibot.Category object of the old category
+ @param newcat: pywikibot.Category object of the new category
@return: the modified text
+ @rtype: unicode
"""
if site is None:
site = pywikibot.Site()
@@ -752,11 +752,9 @@
r'^[^\S\n]*\[\[\s*(%s)\s*:\s*%s\s*((?:\|[^]]+)?\]\])[^\S\n]*\n'
% (catNamespace, title), re.I | re.M)
if newcat is None:
- """ First go through and try the more restrictive regex that removes
- an entire line, if the category is the only thing on that line (this
- prevents blank lines left over in category lists following a removal.)
- """
-
+ # First go through and try the more restrictive regex that removes
+ # an entire line, if the category is the only thing on that line (this
+ # prevents blank lines left over in category lists following a removal.)
text = replaceExcept(oldtext, categoryRN, '',
['nowiki', 'comment', 'math', 'pre', 'source'])
text = replaceExcept(text, categoryR, '',
@@ -773,12 +771,11 @@
"""
Replace all existing category links with new category links.
- 'new' should be a list of Category objects or strings
- which can be either the raw name or [[Category:..]].
-
- If addOnly is True, the old category won't be deleted and the
- category(s) given will be added (and so they won't replace anything).
-
+ @param oldtext: The text that needs to be replaced.
+ @param new: Should be a list of Category objects or strings
+ which can be either the raw name or [[Category:..]].
+ @param addOnly: If addOnly is True, the old category won't be deleted and the
+ category(s) given will be added (and so they won't replace anything).
"""
# Find a marker that is not already in the text.
marker = findmarker(oldtext)
@@ -841,7 +838,6 @@
which can be either the raw name or [[Category:..]].
The string is formatted for inclusion in insite.
-
"""
if not categories:
return ''
@@ -951,7 +947,6 @@
@return: list of template name and params
@rtype: list of tuple
"""
-
# remove commented-out stuff etc.
thistxt = removeDisabledParts(text)
@@ -1108,7 +1103,6 @@
You can use items from extract_templates_and_params here to get
an equivalent template wiki text (it may happen that the order
of the params changes).
-
"""
(template, params) = template_and_params
text = u''
@@ -1136,7 +1130,6 @@
If a section parameter contains a internal link, it will match the
section with or without a preceding colon which is required for a
text link e.g. for categories and files.
-
"""
# match preceding colon for text links
section = re.sub(r'\\\[\\\[(\\\:)?', '\[\[\:?', re.escape(section))
@@ -1155,8 +1148,9 @@
"""
Class building tzinfo objects for fixed-offset time zones.
- @offset: a number indicating fixed offset in minutes east from UTC
- @name: a string with name of the timezone"""
+ @param offset: a number indicating fixed offset in minutes east from UTC
+ @param name: a string with name of the timezone
+ """
def __init__(self, offset, name):
self.__offset = datetime.timedelta(minutes=offset)
@@ -1248,7 +1242,9 @@
def last_match_and_replace(self, txt, pat):
"""
- Take the rightmost match, to prevent spurious earlier matches, and replace with marker.
+ Take the rightmost match and replace with marker.
+
+ It does so to prevent spurious earlier matches.
"""
m = None
cnt = 0
@@ -1279,7 +1275,6 @@
All the following items must be matched, otherwise None is returned:
-. year, month, hour, time, day, minute, tzinfo
-
"""
# match date fields
dateDict = dict()
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index ffd4367..003b522 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-Mechanics to slow down wiki read and/or write rate.
-"""
+"""Mechanics to slow down wiki read and/or write rate."""
#
# (C) Pywikibot team, 2008
#
@@ -180,7 +178,7 @@
return thisdelay
def waittime(self, write=False):
- """Return waiting time in seconds if a query would be made right now"""
+ """Return waiting time in seconds if a query would be made right now."""
# Take the previous requestsize in account calculating the desired
# delay this time
thisdelay = self.getDelay(write=write)
diff --git a/pywikibot/version.py b/pywikibot/version.py
index 7ca8a0c..c8cb36c 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -23,7 +23,7 @@
class ParseError(Exception):
- """ Parsing went wrong. """
+ """Parsing went wrong."""
def _get_program_dir():
@@ -260,6 +260,12 @@
Extracts __version__ variable containing Id tag, without importing it.
(thus can be done for any file)
+
+ The version variable containing the Id tag is read and
+ returned. Because it doesn't import it, the version can
+ be retrieved from any file.
+ @param filename: Name of the file to get version
+ @type filename: string
"""
_program_dir = _get_program_dir()
__version__ = None
diff --git a/pywikibot/xmlreader.py b/pywikibot/xmlreader.py
index e327b6e..56993c4 100644
--- a/pywikibot/xmlreader.py
+++ b/pywikibot/xmlreader.py
@@ -46,9 +46,8 @@
class XmlEntry:
- """
- Represents a page.
- """
+ """Represent a page."""
+
def __init__(self, title, ns, id, text, username, ipedit, timestamp,
editRestriction, moveRestriction, revisionid, comment,
redirect):
--
To view, visit https://gerrit.wikimedia.org/r/157334
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic65452262d16ba2ec83633125ce1e3145a6f3aef
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Use relative import of upload in data_ingestion
......................................................................
Use relative import of upload in data_ingestion
py3 nosetests fails on 'import upload' in the
data_ingestion script, causing a travis build breakage.
Two other scripts use 'import upload'
- flickrripper
- imagetransfer
And other use 'import <script>' syntax, which will
also fail on py3 nosetests when we have tests for
them.
This change only updates data_ingestion to use
the 'from scripts import upload' import style, to fix
the build breakage while waiting on feedback from nosetests
https://github.com/nose-devs/nose/issues/839
Also update data_ingestion tests to use the new test metaclass.
Change-Id: If40087657718749dd54a37834d551f97424b4914
---
M scripts/data_ingestion.py
M tests/data_ingestion_tests.py
2 files changed, 15 insertions(+), 4 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/data_ingestion.py b/scripts/data_ingestion.py
index 83ec1c0..e62ce32 100755
--- a/scripts/data_ingestion.py
+++ b/scripts/data_ingestion.py
@@ -15,7 +15,10 @@
import sys
import pywikibot
-import upload
+# TODO: nosetests3 fails on 'import <other_script>', which is used by many
+# of our scripts, but only data_ingestion is directly imported (not via pwb).
+# https://github.com/nose-devs/nose/issues/839
+from scripts import upload
if sys.version_info[0] > 2:
from urllib.parse import urlparse
diff --git a/tests/data_ingestion_tests.py b/tests/data_ingestion_tests.py
index 8a877e3..741ccef 100644
--- a/tests/data_ingestion_tests.py
+++ b/tests/data_ingestion_tests.py
@@ -5,12 +5,16 @@
__version__ = '$Id$'
import os
-from tests import unittest
+from tests.aspects import unittest, TestCase
from scripts import data_ingestion
-class TestPhoto(unittest.TestCase):
+class TestPhoto(TestCase):
+
+ net = True
+
def setUp(self):
+ super(TestPhoto, self).setUp()
self.obj = data_ingestion.Photo(URL='http://upload.wikimedia.org/wikipedia/commons/f/fc/MP_sounds.png',
metadata={'description.en': '"Sounds" icon',
'source': 'http://commons.wikimedia.org/wiki/File:Sound-icon.svg',
@@ -43,8 +47,12 @@
}}""") # noqa
-class TestCSVReader(unittest.TestCase):
+class TestCSVReader(TestCase):
+
+ net = False
+
def setUp(self):
+ super(TestCSVReader, self).setUp()
fileobj = open(os.path.join(os.path.split(__file__)[0], 'data', 'csv_ingestion.csv'))
self.iterator = data_ingestion.CSVReader(fileobj, 'url')
self.obj = next(self.iterator)
--
To view, visit https://gerrit.wikimedia.org/r/159410
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If40087657718749dd54a37834d551f97424b4914
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add function to determine datatype of a wikidata property via API instead of via "isinstance"
......................................................................
Add function to determine datatype of a wikidata property via API instead of via "isinstance"
Bug: 54543
Change-Id: Ie7ebb9b2d3636b5e4f98c42ff81422359cf07cd3
---
M wikipedia.py
1 file changed, 9 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
Objections:
Ladsgroup: There's a problem with this change, please improve
diff --git a/wikipedia.py b/wikipedia.py
index bddc1d7..51c60ca 100644
--- a/wikipedia.py
+++ b/wikipedia.py
@@ -4649,6 +4649,15 @@
return 302, response.msg, data['success']
return response.code, response.msg, data
+ def getPropertyType(self, prop):
+ params = {
+ 'action': 'wbgetentities',
+ 'ids': prop,
+ 'props': 'datatype',
+ }
+ data = query.GetData(params, self.site())
+ return data['entities']['datatype']
+
def editclaim(self, WDproperty, value, data_type=None, raw_value=False,
refs=None, comment=None, token=None, sysop=False,
botflag=True):
--
To view, visit https://gerrit.wikimedia.org/r/92074
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie7ebb9b2d3636b5e4f98c42ff81422359cf07cd3
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: Beta16 <l.rabinelli(a)gmail.com>
Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add all dependencies in setup.py&requirements.txt
......................................................................
Add all dependencies in setup.py&requirements.txt
Add setup.py extra dependencies:
- daemonize
- pydot
- oursql
- yahoo
- google
- irc
- mwparserfromhell
Add test dependencies:
- pywin32
- pywinauto
Add all dependencies to new file requirements.txt
Change-Id: Ie214e7666eb2d2bb967b3fb6420f733e5d8919e9
---
A requirements.txt
M setup.py
2 files changed, 74 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..08d005c
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,58 @@
+# This is a PIP requirements file
+#
+# All dependencies can be installed using:
+# $ sudo pip install -r requirements.txt
+#
+# It is organised so that simple requirements
+# are processed first, and more difficult packages
+# are last.
+# All dependencies other than httplib2 are optional.
+#
+# It is good practise to install packages using the system
+# package manager if it has a packaged version. If you are
+# unsure, please use pip as described at the top of the file.
+#
+# To get a list of potential matches, use
+#
+# $ awk -F '[#>=]' '{print $1}' requirements.txt | xargs yum search
+# or
+# $ awk -F '[#>=]' '{print $1}' requirements.txt | xargs apt-cache search
+
+# mandatory; see README.conversion.txt
+httplib2>=0.9.0
+
+# core option 'daemonize':
+daemonize
+
+# core interwiki_graph.py:
+pydot
+
+# core pagegenerators
+yahoo
+google
+
+# scripts/script_wui.py:
+crontab
+
+# scipts/replicate_wiki.py
+argparse
+
+# scripts/flickrripper.py
+Pillow
+flickrapi
+
+# scripts/tests/test_data_ingestion.py
+test_utils
+
+# incomplete core component botirc
+irc
+
+# textlib.py
+mwparserfromhell>=0.3.3
+
+# The mysql generator in pagegenerators depends on either oursql or MySQLdb
+# pywikibot prefers oursql
+oursql
+
+# scripts/script_wui.py depends on Lua, which is not available using pip
+# but can be obtained from: https://github.com/bastibe/lunatic-python
diff --git a/setup.py b/setup.py
index 86102fb..df8abaa 100644
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,16 @@
dependencies = ['httplib2>=0.6.0']
-extra_deps = {}
+extra_deps = {
+ # Core library dependencies
+ 'daemonize': ['daemonize'],
+ 'Graphviz': ['pydot'],
+ 'MySQL': ['oursql'],
+ 'Yahoo': ['yahoo'],
+ 'Google': ['google'],
+ 'IRC': ['irc'],
+ 'mwparserfromhell': ['mwparserfromhell>=0.3.3']
+}
script_deps = {
'script_wui.py': ['irc', 'lunatic-python', 'crontab'],
@@ -53,7 +62,12 @@
if os.name != 'nt':
# See bug 66010, Windows users will have issues
# when trying to build the C modules.
- dependencies.append('mwparserfromhell>=0.3.3')
+ dependencies += extra_deps['mwparserfromhell']
+
+if os.name == 'nt':
+ # FIXME: tests/ui_tests.py suggests pywinauto 0.4.2
+ # which isnt provided on pypi.
+ test_deps += ['pywin32>=218', 'pywinauto>=0.4.0']
extra_deps.update(script_deps)
# Add script dependencies as test dependencies,
--
To view, visit https://gerrit.wikimedia.org/r/159269
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie214e7666eb2d2bb967b3fb6420f733e5d8919e9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove old testing comment in date.py
......................................................................
Remove old testing comment in date.py
Change-Id: I66c27e67484ef1ace1fb3d6bdd5d84867146ec07
---
M pywikibot/date.py
1 file changed, 0 insertions(+), 6 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index 60edd0d..94f1dc7 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -489,12 +489,6 @@
# or not, or generating dates.
# See dh() for additional information.
#
-#
-# *********** ATTENTION! ***********
-#
-# You must test this table before submitting it to CVS by calling
-# date.test() method
-#
formats = {
'MonthName': {
'af': lambda v: slh(v, [u"Januarie", u"Februarie", u"Maart", u"April",
--
To view, visit https://gerrit.wikimedia.org/r/159170
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I66c27e67484ef1ace1fb3d6bdd5d84867146ec07
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
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]
--
To view, visit https://gerrit.wikimedia.org/r/159223
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I60417587c65711974f5a3ef3096cf6faa005cb2e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot <>