jenkins-bot has submitted this change and it was merged.
Change subject: Tox entry point to lint docstrings
......................................................................
Tox entry point to lint docstrings
pep257 define a standard for docstrings. The linter is available as a
flake8 extension 'flake8-docstrings'.
Hack in the flake8 command to only include errors starting with D.
Usage:
tox -e flake8-docstrings
Change-Id: If8b5788aee1e64db8accead39c3058057874932b
---
M tox.ini
1 file changed, 5 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
Multichill: Looks good to me, but someone else must approve
jenkins-bot: Verified
Objections:
Hashar: There's a problem with this change, please improve
diff --git a/tox.ini b/tox.ini
index 5a6209e..5e8d79a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
-envlist = flake8,py26,py27
+envlist = flake8,flake8-docstrings,py26,py27
[testenv]
setenv = VIRTUAL_ENV={envdir}
@@ -13,6 +13,10 @@
commands = flake8 {posargs}
deps = flake8
+[testenv:flake8-docstrings]
+commands = flake8 --select=D {posargs}
+deps = flake8-docstrings
+
[testenv:venv]
commands = {posargs}
--
To view, visit https://gerrit.wikimedia.org/r/139412
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If8b5788aee1e64db8accead39c3058057874932b
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
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: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Replace site.language() with site.code
......................................................................
Replace site.language() with site.code
Change-Id: I5bbc64720051ed504cff8328e2ea2eeef82dbf96
---
M scripts/commonscat.py
1 file changed, 13 insertions(+), 15 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index de2ba91..d7c7e4c 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -318,24 +318,22 @@
return False
@classmethod
- def getCommonscatTemplate(self, lang=None):
- """Get the template name in a language. Expects the language code.
+ def getCommonscatTemplate(self, code=None):
+ """Get the template name of a site. Expects the site code.
Return as tuple containing the primary template and it's alternatives
"""
- if lang in commonscatTemplates:
- return commonscatTemplates[lang]
+ if code in commonscatTemplates:
+ return commonscatTemplates[code]
else:
return commonscatTemplates[u'_default']
def skipPage(self, page):
- '''
- Do we want to skip this page?
- '''
- if page.site.language() in ignoreTemplates:
+ """Do we want to skip this page?"""
+ if page.site.code in ignoreTemplates:
templatesInThePage = page.templates()
templatesWithParams = page.templatesWithParams()
- for template in ignoreTemplates[page.site.language()]:
+ for template in ignoreTemplates[page.site.code]:
if not isinstance(template, tuple):
for pageTemplate in templatesInThePage:
if pageTemplate.title(withNamespace=False) == template:
@@ -356,7 +354,7 @@
pywikibot.output(u'Working on ' + page.title())
# Get the right templates for this page
primaryCommonscat, commonscatAlternatives = self.getCommonscatTemplate(
- page.site.language())
+ page.site.code)
commonscatLink = self.getCommonscatLink(page)
if commonscatLink:
pywikibot.output(u'Commonscat template is already on %s'
@@ -458,7 +456,7 @@
if (checkedCommonscat != u''):
pywikibot.output(
u"Found link for %s at [[%s:%s]] to %s."
- % (page.title(), ipage.site.language(),
+ % (page.title(), ipage.site.code,
ipage.title(), checkedCommonscat))
return checkedCommonscat
except pywikibot.BadTitle:
@@ -467,11 +465,11 @@
return u''
def getCommonscatLink(self, wikipediaPage=None):
- '''
+ """
Go through the page and return a tuple of (<templatename>, <target>)
- '''
+ """
primaryCommonscat, commonscatAlternatives = self.getCommonscatTemplate(
- wikipediaPage.site.language())
+ wikipediaPage.site.code)
commonscatTemplate = u''
commonscatTarget = u''
commonscatLinktext = u''
@@ -575,7 +573,7 @@
checkcurrent = True
primaryCommonscat, commonscatAlternatives = \
CommonscatBot.getCommonscatTemplate(
- pywikibot.Site().language())
+ pywikibot.Site().code)
generator = pagegenerators.NamespaceFilterPageGenerator(
pagegenerators.ReferringPageGenerator(
pywikibot.Page(pywikibot.Site(),
--
To view, visit https://gerrit.wikimedia.org/r/137021
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5bbc64720051ed504cff8328e2ea2eeef82dbf96
Gerrit-PatchSet: 6
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.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: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Bump Wikimedia family version to 1.24wmf8
......................................................................
Bump Wikimedia family version to 1.24wmf8
This is needed to complement I2c164208aa10dc893693c520d38f0386be202d5e
Change-Id: I639029f1aeffb047cc2f47340107f137434f08ce
---
M pywikibot/family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index d98a2b8..f641bd6 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1075,7 +1075,7 @@
"""
# Here we return the latest mw release of wikimedia projects
- return '1.24wmf7'
+ return '1.24wmf8'
def shared_image_repository(self, code):
return ('commons', 'commons')
--
To view, visit https://gerrit.wikimedia.org/r/139319
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I639029f1aeffb047cc2f47340107f137434f08ce
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove GoogleSearchGenerator which does not work anymore
......................................................................
Remove GoogleSearchGenerator which does not work anymore
Change-Id: I737a67766340e10b6bbaa7f1ae183a3e3db52b43
---
M config.py
M pagegenerators.py
2 files changed, 0 insertions(+), 132 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
Withoutaname: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/config.py b/config.py
index c10cefb..50fafa2 100644
--- a/config.py
+++ b/config.py
@@ -343,20 +343,6 @@
############## SEARCH ENGINE SETTINGS ##############
-# Some scripts allow querying Google via the Google Web API. To use this
-# feature, you must install the pyGoogle module from http://pygoogle.sf.net/
-# and have a Google Web API license key. Note that Google doesn't give out
-# license keys anymore.
-# --------------------
-# Google web API is obsoleted for long time, now we can use Google AJAX Search
-# API. You can signup an API key from
-# http://code.google.com/apis/ajaxsearch/signup.html.
-google_key = ''
-
-# using Google AJAX Search API, it requires the referer website, this variable
-# saves the referer web address when you sign up with the key.
-google_api_refer = ''
-
# Some scripts allow using the Yahoo! Search Web Services. To use this feature,
# you must install the pYsearch module from http://pysearch.sourceforge.net/
# and get a Yahoo AppID from http://developer.yahoo.com
diff --git a/pagegenerators.py b/pagegenerators.py
index 4b57567..20cc3c5 100644
--- a/pagegenerators.py
+++ b/pagegenerators.py
@@ -186,12 +186,6 @@
"-redirectonly:Template:!" will make the bot work on
all redirect pages in the template namespace.
--google Work on all pages that are found in a Google search.
- You need a Google Web API license key. Note that Google
- doesn't give out license keys anymore. See google_key in
- config.py for instructions.
- Argument can also be given as "-google:searchstring".
-
-yahoo Work on all pages that are found in a Yahoo search.
Depends on python module pYsearch. See yahoo_appid in
config.py for instructions.
@@ -505,8 +499,6 @@
u'What do you want to search for?')
gen = SearchPageGenerator(mediawikiQuery, number=None,
namespaces=self.getNamespaces)
- elif arg.startswith('-google'):
- gen = GoogleSearchPageGenerator(arg[8:])
elif arg.startswith('-titleregex'):
if len(arg) == 11:
regex = pywikibot.input(u'What page names are you looking for?')
@@ -901,116 +893,6 @@
title = url[len(base):]
page = pywikibot.Page(self.site, title)
yield page
-
-
-class GoogleSearchPageGenerator:
- """
- To use this generator, you must install the pyGoogle module from
- http://pygoogle.sf.net/ and get a Google Web API license key from
- http://www.google.com/apis/index.html . The google_key must be set to your
- license key in your configuration.
-
- """
-
- def __init__(self, query=None, site=None):
- self.query = query or pywikibot.input(u'Please enter the search query:')
- if site is None:
- site = pywikibot.getSite()
- self.site = site
-
- #########
- # partially commented out because it is probably not in compliance with
- # Google's "Terms of service"
- # (see 5.3, http://www.google.com/accounts/TOS?loc=US)
- def queryGoogle(self, query):
- #if config.google_key:
- if True:
- try:
- for url in self.queryViaSoapApi(query):
- yield url
- return
- except ImportError:
- for u in self.queryViaAPI(query):
- yield u
- return
- # No google license key, or pygoogle not installed. Do it the ugly way.
- #for url in self.queryViaWeb(query):
- # yield url
-
- def queryViaAPI(self, query):
- try:
- import json
- except ImportError:
- import simplejson as json
- url = u'http://ajax.googleapis.com/ajax/services/search/web?'
- params = {
- 'key': config.google_key,
- 'v': '1.0',
- 'q': query,
- }
- url += urllib.urlencode(params)
-
- while True:
- try:
- pywikibot.output(u'Querying Google AJAX Search API...')
- result = json.loads(
- self.site.getUrl(url, refer=config.google_api_refer,
- no_hostname=True))
- for res in result['responseData']['results']:
- yield res['url']
- except:
- pywikibot.output(u"An error occured. Retrying in 10 seconds...")
- time.sleep(10)
- continue
-
- def queryViaSoapApi(self, query):
- import google
- google.LICENSE_KEY = config.google_key
- offset = 0
- estimatedTotalResultsCount = None
- while not estimatedTotalResultsCount or \
- offset < estimatedTotalResultsCount:
- while True:
- # Google often yields 502 errors.
- try:
- pywikibot.output(u'Querying Google, offset %i' % offset)
- data = google.doGoogleSearch(query, start=offset,
- filter=False)
- break
- except KeyboardInterrupt:
- raise
- except:
- # SOAPpy.Errors.HTTPError or SOAP.HTTPError
- # (502 Bad Gateway) can happen here, depending on the module
- # used. It's not easy to catch this properly because
- # pygoogle decides which one of the soap modules to use.
- pywikibot.output(u"An error occured. "
- u"Retrying in 10 seconds...")
- time.sleep(10)
- continue
-
- for result in data.results:
- yield result.URL
- # give an estimate of pages to work on, but only once.
- if not estimatedTotalResultsCount:
- pywikibot.output(u'Estimated total result count: %i pages.'
- % data.meta.estimatedTotalResultsCount)
- estimatedTotalResultsCount = data.meta.estimatedTotalResultsCount
- offset += 10
-
- def __iter__(self):
- # restrict query to local site
- localQuery = '%s site:%s' % (self.query, self.site.hostname())
- base = 'http://%s%s' % (self.site.hostname(),
- self.site.nice_get_address(''))
- for url in self.queryGoogle(localQuery):
- if url[:len(base)] == base:
- title = url[len(base):]
- page = pywikibot.Page(self.site, title)
- # Google contains links in the format
- # http://de.wikipedia.org/wiki/en:Foobar
- if page.site == self.site:
- yield page
def MySQLPageGenerator(query, site=None):
--
To view, visit https://gerrit.wikimedia.org/r/136322
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I737a67766340e10b6bbaa7f1ae183a3e3db52b43
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Alex S.H. Lin <alexsh(a)mail2000.com.tw>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Withoutaname <drevitchi(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: use site methods instead of family methods
......................................................................
use site methods instead of family methods
- remove BaseSite.linktrail() which is already derived from
Family.linktrail(code) by BaseSite.__getattr__()
- port the doc string to the corresponding family method
- remove BaseSite.nice_get_address() which is already derived from
Family.nice_get_address(code) by BaseSite.__getattr__()
- use methods version(), protocol(), hostname()
Change-Id: I33c9e6db6c2797bb7e637f3c46cb8af7f08037b8
---
M pywikibot/family.py
M pywikibot/site.py
2 files changed, 13 insertions(+), 21 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index b55a761..955e815 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -852,6 +852,16 @@
return self.known_families
def linktrail(self, code, fallback='_default'):
+ """Return regex for trailing chars displayed as part of a link.
+
+ Returns a string, not a compiled regular expression object.
+
+ This reads from the family file, and ''not'' from
+ [[MediaWiki:Linktrail]], because the MW software currently uses a
+ built-in linktrail from its message files and ignores the wiki
+ value.
+
+ """
if code in self.linktrails:
return self.linktrails[code]
elif fallback:
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 971edc5..62d6553 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -234,19 +234,6 @@
def __hash__(self):
return hash(repr(self))
- def linktrail(self):
- """Return regex for trailing chars displayed as part of a link.
-
- Returns a string, not a compiled regular expression object.
-
- This reads from the family file, and ''not'' from
- [[MediaWiki:Linktrail]], because the MW software currently uses a
- built-in linktrail from its message files and ignores the wiki
- value.
-
- """
- return self.family.linktrail(self.code)
-
def languages(self):
"""Return list of all valid language codes for this site's Family."""
@@ -488,11 +475,6 @@
return pywikibot.Site(code=code, fam=self.family, user=self.user())
- def nice_get_address(self, title):
- """Return shorter URL path to retrieve page titled 'title'."""
-
- return self.family.nice_get_address(self.lang, title)
-
# deprecated methods for backwards-compatibility
@deprecated("family attribute")
@@ -645,7 +627,7 @@
14: [u"Category"],
15: [u"Category talk"],
}
- if LV(self.family.version(self.code)) >= LV("1.14"):
+ if LV(self.version()) >= LV("1.14"):
self._namespaces[6] = [u"File"]
self._namespaces[7] = [u"File talk"]
self._msgcache = {}
@@ -2858,8 +2840,8 @@
elif "url" in captcha:
import webbrowser
webbrowser.open('%s://%s%s'
- % (self.family.protocol(self.code),
- self.family.hostname(self.code),
+ % (self.protocol(),
+ self.hostname(),
captcha["url"]))
req['captchaword'] = cap_answerwikipedia.input(
"Please view CAPTCHA in your browser, "
--
To view, visit https://gerrit.wikimedia.org/r/138329
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I33c9e6db6c2797bb7e637f3c46cb8af7f08037b8
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: (bug 66445) New "prop" parameter with action=expandtemplates
......................................................................
(bug 66445) New "prop" parameter with action=expandtemplates
In 1.24wmf8, expandtemplates without prop parameter causes API warning.
Change-Id: I2c164208aa10dc893693c520d38f0386be202d5e
---
M pywikibot/site.py
1 file changed, 7 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 971edc5..abdb9a0 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -4,7 +4,7 @@
on the same topic in different languages).
"""
#
-# (C) Pywikibot team, 2008-2012
+# (C) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
@@ -1033,7 +1033,12 @@
req['title'] = title
if includecomments is True:
req['includecomments'] = u''
- return req.submit()['expandtemplates']['*']
+ if LV(self.version()) > LV("1.24wmf7"):
+ key = 'wikitext'
+ req['prop'] = key
+ else:
+ key = '*'
+ return req.submit()['expandtemplates'][key]
def getcurrenttimestamp(self):
"""Return server time, {{CURRENTTIMESTAMP}}, as a string.
--
To view, visit https://gerrit.wikimedia.org/r/139099
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2c164208aa10dc893693c520d38f0386be202d5e
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>