jenkins-bot has submitted this change and it was merged.
Change subject: There is no need for gen in clean_sandbox.py
......................................................................
There is no need for gen in clean_sandbox.py
It was a mistake added in 9dc69a9c. When a gen is not defined
SandboxBot handles the matter itself and defines
sandbox of the site as gen to run.
Change-Id: I116e46be739126fbb8b481e265271a267ab67f5b
---
M scripts/clean_sandbox.py
1 file changed, 3 insertions(+), 8 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index 9df6529..590db4b 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -170,8 +170,7 @@
raise RuntimeError
if not self.generator:
if self.site.code not in sandboxTitle:
- pywikibot.error(u'No generator is given for this site'
- u'(%s), exiting.' % self.site)
+ pywikibot.bot.suggest_help(missing_generator=True)
raise RuntimeError
local_sandbox_title = sandboxTitle[self.site.code]
if not isinstance(local_sandbox_title, list):
@@ -288,13 +287,9 @@
generator = gen_factory.getCombinedGenerator()
- if generator:
- bot = SandboxBot(generator=generator, **opts)
- bot.run()
- return True
+ bot = SandboxBot(generator=generator, **opts)
+ bot.run()
- pywikibot.bot.suggest_help(missing_generator=True)
- return False
if __name__ == "__main__":
main()
--
To view, visit https://gerrit.wikimedia.org/r/240399
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I116e46be739126fbb8b481e265271a267ab67f5b
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Fix errors in proofreadpage.py and djvutxt.py
......................................................................
[FIX] Fix errors in proofreadpage.py and djvutxt.py
Fix following errors in djvu.txt.py:
- default pages: start=1, end=number of pages in djvu file.
- user name is taken care by ProofreadPage() when preloading.
Fix the follwing in Proofreadpage():
- avoid resetting the page content if self._decompose_page() is called by
self.text property (e.g. when adding user name to the text).
Change-Id: Ied326eece98e42e724b2d8a205366f6cbb17ccab
---
M pywikibot/proofreadpage.py
M scripts/djvutext.py
2 files changed, 3 insertions(+), 6 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index 0703b89..a14e2f2 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -261,7 +261,8 @@
exception Error: the page is not formatted according to ProofreadPage
extension.
"""
- if not self.text: # Property force page text loading.
+ # Property force page text loading.
+ if not (hasattr(self, '_text') or self.text):
self._create_empty_page()
return
diff --git a/scripts/djvutext.py b/scripts/djvutext.py
index 725c489..5f0ee09 100644
--- a/scripts/djvutext.py
+++ b/scripts/djvutext.py
@@ -110,10 +110,6 @@
# Overwrite body of the page with content from djvu
page.body = self._djvu.get_page(page.page_number)
-
- # Add username in header if page does not exists.
- if not page.exists():
- page.user = page.site.user()
new_text = page.text
summary = self.getOption('summary')
@@ -135,7 +131,7 @@
"""
index = None
djvu_path = '.' # default djvu file directory
- pages = '1'
+ pages = '1-'
options = {}
# Parse command line arguments.
--
To view, visit https://gerrit.wikimedia.org/r/240434
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ied326eece98e42e724b2d8a205366f6cbb17ccab
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] APISite: Don't query inprop for redirects
......................................................................
[IMPROV] APISite: Don't query inprop for redirects
The `inprop` entries for `subjectid` and `talkid` were nowhere used so we don't
actually need to query them. And the protection can be loaded afterwards and
don't need to be forced in each response.
Change-Id: I2b2482973aa18451693e0f92523bebd38661b82d
---
M pywikibot/site.py
1 file changed, 0 insertions(+), 1 deletion(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index dab70e5..b45d354 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -2914,7 +2914,6 @@
query = self._simple_request(
action='query',
prop='info',
- inprop=['protection', 'talkid', 'subjectid'],
titles=title,
redirects=True)
result = query.submit()
--
To view, visit https://gerrit.wikimedia.org/r/239665
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I2b2482973aa18451693e0f92523bebd38661b82d
Gerrit-PatchSet: 2
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [i18n] enable twn support
......................................................................
[i18n] enable twn support
Bug: T110856
Change-Id: I664c40ca92f4987365daed574a6b9d0a0218ca89
---
M scripts/imagetransfer.py
1 file changed, 8 insertions(+), 46 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py
index 0df238f..c08653d 100755
--- a/scripts/imagetransfer.py
+++ b/scripts/imagetransfer.py
@@ -27,7 +27,7 @@
"""
#
# (C) Andre Engels, 2004
-# (C) Pywikibot team, 2004-2014
+# (C) Pywikibot team, 2004-2015
#
# Distributed under the terms of the MIT license.
#
@@ -43,26 +43,6 @@
from pywikibot import config, i18n, textlib
from scripts import upload
-
-copy_message = {
- 'ar': u"هذه الصورة تم نقلها من %s. الوصف الأصلي كان:\r\n\r\n%s",
- 'en': u"This image was copied from %s. The original description was:\r\n\r\n%s",
- 'fa': u"تصویر از %s کپی شدهاست.توضیحات اصلی ان این بود::\r\n\r\n%s",
- 'de': u"Dieses Bild wurde von %s kopiert. Die dortige Beschreibung lautete:\r\n\r\n%s",
- 'fr': u"Cette image est copiée de %s. La description originale était:\r\n\r\n%s",
- 'he': u"תמונה זו הועתקה מהאתר %s. תיאור הקובץ המקורי היה:\r\n\r\n%s",
- 'hu': u"Kép másolása innen: %s. Az eredeti leírás:\r\n\r\n%s",
- 'ia': u"Iste imagine esseva copiate de %s. Le description original esseva:\r\n\r\n%s",
- 'it': u"Questa immagine è stata copiata da %s. La descrizione originale era:\r\n\r\n%s",
- 'kk': u"Бұл сурет %s дегеннен көшірілді. Түпнұсқа сипатттамасы былай болды:\r\n\r\n%s",
- 'lt': u"Šis paveikslėlis buvo įkeltas iš %s. Originalus aprašymas buvo:\r\n\r\n%s",
- 'nl': u"Afbeelding gekopieerd vanaf %s. De beschrijving daar was:\r\n\r\n%s",
- 'pl': u"Ten obraz został skopiowany z %s. Oryginalny opis to:\r\n\r\n%s",
- 'pt': u"Esta imagem foi copiada de %s. A descrição original foi:\r\n\r\n%s",
- 'ru': u"Изображение было скопировано с %s. Оригинальное описание содержало:\r\n\r\n%s",
- 'sr': u"Ова слика је копирана са %s. Оригинални опис је:\r\n\r\n%s",
- 'zh': u"本圖像從 %s 複製,原始說明資料:\r\n\r\n%s",
-}
nowCommonsTemplate = {
'ar': u'{{الآن كومنز|%s}}',
@@ -84,27 +64,6 @@
'pt': u'{{NowCommons|%s}}',
'sr': u'{{NowCommons|%s}}',
'zh': u'{{NowCommons|Image:%s}}',
-}
-
-nowCommonsMessage = {
- 'ar': u'الملف الآن متوفر في ويكيميديا كومنز.',
- 'de': u'Datei ist jetzt auf Wikimedia Commons verfügbar.',
- 'en': u'File is now available on Wikimedia Commons.',
- 'eo': u'Dosiero nun estas havebla en la Wikimedia-Komunejo.',
- 'fa': u'پرونده اکنون در انبار است',
- 'he': u'הקובץ זמין כעת בוויקישיתוף.',
- 'hu': u'A fájl most már elérhető a Wikimedia Commonson',
- 'ia': u'Le file es ora disponibile in Wikimedia Commons.',
- 'ja': u'ファイルはウィキメディア・コモンズにあります',
- 'it': u'L\'immagine è adesso disponibile su Wikimedia Commons.',
- 'kk': u'Файлды енді Wikimedia Ортаққорынан қатынауға болады.',
- 'lt': u'Failas įkeltas į Wikimedia Commons projektą.',
- 'nl': u'Dit bestand staat nu op [[w:nl:Wikimedia Commons|Wikimedia Commons]].',
- 'pl': u'Plik jest teraz dostępny na Wikimedia Commons.',
- 'pt': u'Arquivo está agora na Wikimedia Commons.',
- 'ru': u'[[ВП:КБУ#Ф8|Ф.8]]: доступно на [[Викисклад]]е',
- 'sr': u'Слика је сада доступна и на Викимедија Остави.',
- 'zh': u'檔案已存在於維基共享資源。',
}
# Translations for license templates.
@@ -192,8 +151,10 @@
['comment', 'math',
'nowiki', 'pre'])
- description = i18n.translate(self.targetSite, copy_message,
- fallback=True) % (sourceSite, description)
+ description = i18n.twtranslate(self.targetSite,
+ 'imagetransfer-file_page_message',
+ dict(site=sourceSite,
+ description=description))
description += '\n\n'
description += sourceImagePage.getFileVersionHistoryTable()
# add interwiki link
@@ -217,7 +178,8 @@
if targetFilename and self.targetSite.family.name == 'commons' and \
self.targetSite.code == 'commons':
# upload to Commons was successful
- reason = i18n.translate(sourceSite, nowCommonsMessage, fallback=True)
+ reason = i18n.twtranslate(sourceSite,
+ 'imagetransfer-nowcommons_notice')
# try to delete the original image if we have a sysop account
if sourceSite.family.name in config.sysopnames and \
sourceSite.lang in config.sysopnames[sourceSite.family.name]:
@@ -232,7 +194,7 @@
sourceImagePage.put(sourceImagePage.get() + '\n\n' +
nowCommonsTemplate[sourceSite.lang]
% targetFilename,
- summary=nowCommonsMessage[sourceSite.lang])
+ summary=reason)
def showImageList(self, imagelist):
for i in range(len(imagelist)):
--
To view, visit https://gerrit.wikimedia.org/r/239667
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I664c40ca92f4987365daed574a6b9d0a0218ca89
Gerrit-PatchSet: 1
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: 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: Deprecate ParamInfo.query_modules_with_limits
......................................................................
Deprecate ParamInfo.query_modules_with_limits
query_modules_with_limits is an unnecessary performance hit
during site initialisation, and causes problems in production
when there are problems with a query module.
It also causes a paraminfo caching bug to become a major bug
preventing all access due to an assert added in 424eaa3.
Bug: T100779
Bug: T109168
Change-Id: I90910e52395f1db72f51088fa4306f62b625cc2c
---
M pywikibot/data/api.py
M tests/api_tests.py
M tests/utils.py
3 files changed, 29 insertions(+), 8 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index f3772c7..e3e5a8a 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1034,6 +1034,7 @@
if self[mod][attribute])
@property
+ @deprecated('parameter()')
def query_modules_with_limits(self):
"""Set of all query modules which have limits."""
if not self._with_limits:
@@ -2467,10 +2468,11 @@
parameters['continue'] = True
self.request = self.request_class(**kwargs)
- # This forces all paraminfo for all query modules to be bulk loaded.
- limited_modules = (
- set(self.modules) & self.site._paraminfo.query_modules_with_limits
- )
+ self.site._paraminfo.fetch('query+' + mod for mod in self.modules)
+
+ limited_modules = set(
+ mod for mod in self.modules
+ if self.site._paraminfo.parameter('query+' + mod, 'limit'))
if not limited_modules:
self.limited_module = None
@@ -2481,7 +2483,7 @@
# Query will continue as needed until limit (if any) for this module
# is reached.
for module in self.modules:
- if module in self.site._paraminfo.query_modules_with_limits:
+ if module in limited_modules:
self.limited_module = module
limited_modules.remove(module)
break
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 6cb0c83..586e15f 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -468,6 +468,19 @@
self.assertFalse(other_modules & pi.modules)
+class TestParaminfoModules(DefaultSiteTestCase):
+
+ """Test loading all paraminfo modules."""
+
+ def test_action_modules(self):
+ """Test loading all action modules."""
+ self.site._paraminfo.fetch(self.site._paraminfo.action_modules)
+
+ def test_query_modules(self):
+ """Test loading all query modules."""
+ self.site._paraminfo.fetch(self.site._paraminfo.query_modules)
+
+
class TestOptionSet(TestCase):
"""OptionSet class test class."""
diff --git a/tests/utils.py b/tests/utils.py
index 79a9244..a08b30e 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -243,14 +243,20 @@
self.prefixes = set()
def fetch(self, modules, _init=False):
- """Prevented method."""
- raise Exception(u'DryParamInfo.fetch(%r, %r) prevented'
- % (modules, _init))
+ """Load dry data."""
+ return [self[mod] for mod in modules]
def parameter(self, module, param_name):
"""Load dry data."""
return self[module][param_name]
+ def __getitem__(self, name):
+ """Return dry data or a dummy parameter block."""
+ try:
+ return super(DryParamInfo, self).__getitem__(name)
+ except KeyError:
+ return {'name': name, 'limit': None}
+
class DummySiteinfo():
--
To view, visit https://gerrit.wikimedia.org/r/236246
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I90910e52395f1db72f51088fa4306f62b625cc2c
Gerrit-PatchSet: 4
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Reduce import dependencies around cosmetic_changes
......................................................................
Reduce import dependencies around cosmetic_changes
There are several imports around cosmetic_changes which depended
on each other, causing complications when adding new imports.
pywikibot.cosmetic_changes imported pagegenerators only for
parameterHelp, which is unused since the module was moved into
the pywikibot package in fd1ba1e48e.
As cosmetic_changes imported scripts.isbn for backwards compatibility,
it inherited isbn's dependency on pagegenerators. The import of
scripts.isbn has been moved into the function where it is used
to delay the import until after initialisation.
As pagegenerators depends on wikidataquery, which depends on page,
the wikidataquery dependency has been moved to be a delayed import
within WikidataQueryPageGenerator.
Also move the import of page module in cosmetic_changes down to
where it is used, so that cosmetic_changes doesnt depend on page
during startup.
Change-Id: I5ec082c65247129454b605781210f09c168b4a51
---
M pywikibot/cosmetic_changes.py
M pywikibot/pagegenerators.py
2 files changed, 19 insertions(+), 29 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index e6b5213..1bde3a9 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -65,33 +65,15 @@
try:
import stdnum.isbn as stdnum_isbn
- scripts_isbn = None
except ImportError:
stdnum_isbn = None
- # Old dependency
- try:
- import scripts.isbn as scripts_isbn
- except ImportError:
- scripts_isbn = None
import pywikibot
-from pywikibot import config, textlib, pagegenerators
-from pywikibot.page import url2unicode
+from pywikibot import config, textlib
from pywikibot.tools import deprecate_arg, first_lower, first_upper
from pywikibot.tools import MediaWikiVersion
-
-warning = """
-ATTENTION: You can run this script as a stand-alone for testing purposes.
-However, the changes that are made are only minor, and other users
-might get angry if you fill the version histories and watchlists with such
-irrelevant changes. Some wikis prohibit stand-alone running."""
-
-docuReplacements = {
- '¶ms;': pagegenerators.parameterHelp,
- '&warning;': warning,
-}
# This is from interwiki.py;
# move it to family file and implement global instances
@@ -159,6 +141,20 @@
def _format_isbn_match(match, strict=True):
"""Helper function to validate and format a single matched ISBN."""
+ scripts_isbn = None
+
+ if not stdnum_isbn:
+ # For backwards compatibility, if stdnum.isbn is not available
+ # attempt loading scripts.isbn as an alternative implementation.
+ try:
+ import scripts.isbn as scripts_isbn
+ except ImportError:
+ raise NotImplementedError(
+ 'ISBN functionality not available. Install stdnum package.')
+
+ warn('package stdnum.isbn not found; using scripts.isbn',
+ ImportWarning)
+
isbn = match.group('code')
if stdnum_isbn:
try:
@@ -194,19 +190,11 @@
@raises Exception: Invalid ISBN encountered when strict enabled
"""
- if not stdnum_isbn:
- if not scripts_isbn:
- raise NotImplementedError(
- 'ISBN functionality not available. Install stdnum package.')
-
- warn('package stdnum.isbn not found; using scripts.isbn',
- ImportWarning)
-
return textlib.reformat_ISBNs(
text, lambda match: _format_isbn_match(match, strict=strict))
-class CosmeticChangesToolkit:
+class CosmeticChangesToolkit(object):
"""Cosmetic changes toolkit."""
@@ -519,6 +507,7 @@
titleLength)
# Convert URL-encoded characters to unicode
+ from pywikibot.page import url2unicode
titleWithSection = url2unicode(titleWithSection,
encodings=self.site)
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index 8e42bf5..9f392f5 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -47,7 +47,6 @@
from pywikibot import date, config, i18n
from pywikibot.comms import http
-from pywikibot.data import wikidataquery as wdquery
from pywikibot.exceptions import ArgumentDeprecationWarning
if sys.version_info[0] > 2:
@@ -2367,6 +2366,8 @@
@type site: L{pywikibot.site.BaseSite}
"""
+ from pywikibot.data import wikidataquery as wdquery
+
if site is None:
site = pywikibot.Site()
repo = site.data_repository()
--
To view, visit https://gerrit.wikimedia.org/r/237537
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5ec082c65247129454b605781210f09c168b4a51
Gerrit-PatchSet: 5
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: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>