Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3071
Status: Errored
Duration: 1 hour, 19 minutes, and 45 seconds
Commit: d616db5 (master)
Author: John Vandenberg
Message: Re-order imports
Use both OpenStack hacking H306 and flake8-import-order I201
to enforce the imports in each group are alphabetically sorted,
and that whitespace is added between types of imports, respectively.
Change-Id: Id3ed6a443c9c14f08c59261ef1cc1727ac324a37
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/18170988b37d...d616db57…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/90034800
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: [bugfix] Ignore asterisk while comparing reported lines
......................................................................
[bugfix] Ignore asterisk while comparing reported lines
cosmetic_changes may add a space between asterisk and text. Comparison
whether the line is already reported will fail in that case.
- Add a space between the * and the text.
- remove preleading unicode indicator and use single quotes for the affected
lines
- replace report_text dict by formatted string
- use tools.StringTypes
reorder code for reporting:
- prevent return statement inside the method
- check whether the file is already reported
before checking the report length
- use reported = True as default return value
Bug: T102467
Change-Id: I46a29e6417b0ffe6abfeb9ee773c19f0af3f7323
---
M scripts/checkimages.py
1 file changed, 28 insertions(+), 51 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 8b6eef8..58ae4c4 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -91,7 +91,6 @@
import re
import time
-import sys
import pywikibot
@@ -100,10 +99,7 @@
from pywikibot.exceptions import NotEmailableError
from pywikibot.family import Family
-from pywikibot.tools import deprecated
-
-if sys.version_info[0] > 2:
- basestring = (str, )
+from pywikibot.tools import deprecated, StringTypes
###############################################################################
# <--------------------------- Change only below! --------------------------->#
@@ -337,26 +333,6 @@
'zh': u'User:Alexsh/checkimagereport',
}
-# Adding the date after the signature.
-timeselected = u' ~~~~~'
-
-# The text added in the report
-report_text = {
- 'commons': u"\n*[[:File:%s]] " + timeselected,
- 'ar': u"\n*[[:ملف:%s]] " + timeselected,
- 'de': u"\n*[[:Datei:%s]] " + timeselected,
- 'en': u"\n*[[:File:%s]] " + timeselected,
- 'fa': u"n*[[:پرونده:%s]] " + timeselected,
- 'ga': u"\n*[[:File:%s]] " + timeselected,
- 'hu': u"\n*[[:Kép:%s]] " + timeselected,
- 'it': u"\n*[[:File:%s]] " + timeselected,
- 'ja': u"\n*[[:File:%s]] " + timeselected,
- 'ko': u"\n*[[:그림:%s]] " + timeselected,
- 'ta': u"\n*[[:படிமம்:%s]] " + timeselected,
- 'ur': u"\n*[[:تصویر:%s]] " + timeselected,
- 'zh': u"\n*[[:File:%s]] " + timeselected,
-}
-
# The summary of the report
msg_comm10 = {
'commons': u'Bot: Updating the log',
@@ -575,11 +551,13 @@
self.logFullError = logFullError
self.logFulNumber = logFulNumber
self.rep_page = i18n.translate(self.site, report_page)
- self.rep_text = i18n.translate(self.site, report_text)
+ self.rep_text = '\n* [[:{0}:%s]] ~~~~~'.format(
+ self.site.namespaces.FILE.custom_name)
self.com = i18n.translate(self.site, msg_comm10)
hiddentemplatesRaw = i18n.translate(self.site, HiddenTemplate)
- self.hiddentemplates = set([pywikibot.Page(self.site, tmp)
- for tmp in hiddentemplatesRaw])
+ self.hiddentemplates = set(
+ [pywikibot.Page(self.site, tmp, ns=self.site.namespaces.TEMPLATE)
+ for tmp in hiddentemplatesRaw])
self.pageHidden = i18n.translate(self.site, PageWithHiddenTemplates)
self.pageAllowed = i18n.translate(self.site, PageWithAllowedTemplates)
self.comment = i18n.twtranslate(self.site.lang,
@@ -721,7 +699,7 @@
pywikibot.output(
u"Seems that %s has only the description and not the file..."
% self.image_to_report)
- repme = u"\n*[[:File:%s]] problems '''with the APIs'''"
+ repme = "\n* [[:File:%s]] problems '''with the APIs'''"
self.report_image(self.image_to_report, self.rep_page, self.com,
repme)
return
@@ -866,7 +844,7 @@
@deprecated('Page.revision_count()')
def countEdits(self, pagename, userlist):
"""Function to count the edit of a user or a list of users in a page."""
- if isinstance(userlist, basestring):
+ if isinstance(userlist, StringTypes):
userlist = [userlist]
page = pywikibot.Page(self.site, pagename)
return page.revision_count(userlist)
@@ -914,8 +892,8 @@
# It's not only on commons but the image needs a check
# the second usually is a url or something like that.
# Compare the two in equal way, both url.
- repme = (u"\n*[[:File:%s]] is also on '''Commons''': "
- u"[[commons:File:%s]]"
+ repme = ("\n* [[:File:%s]] is also on '''Commons''': "
+ "[[commons:File:%s]]"
% (self.imageName,
commons_image_with_this_hash.title(
withNamespace=False)))
@@ -1050,18 +1028,18 @@
if self.duplicatesReport or only_report:
if only_report:
- repme = (u"\n*[[:File:%s]] has the following duplicates "
- u"('''forced mode'''):"
+ repme = ('\n* [[:File:%s]] has the following duplicates '
+ "('''forced mode'''):"
% self.image.title(asUrl=True))
else:
- repme = (u"\n*[[:File:%s]] has the following duplicates:"
+ repme = ('\n* [[:File:%s]] has the following duplicates:'
% self.image.title(asUrl=True))
for dup_page in duplicates:
if dup_page.title(asUrl=True) == self.image.title(asUrl=True):
# the image itself, not report also this as duplicate
continue
- repme += u"\n**[[:File:%s]]" % dup_page.title(asUrl=True)
+ repme += '\n** [[:File:%s]]' % dup_page.title(asUrl=True)
result = self.report_image(self.imageName, self.rep_page,
self.com, repme, addings=False)
@@ -1098,7 +1076,19 @@
except pywikibot.IsRedirectPage:
text_get = another_page.getRedirectTarget().get()
- if len(text_get) >= self.logFulNumber:
+ # Don't care for differences inside brackets.
+ end = rep_text.find('(', max(0, rep_text.find(']]')))
+ if end < 0:
+ end = None
+ short_text = rep_text[rep_text.find('[['):end].strip()
+
+ reported = True
+ # Skip if the message is already there.
+ if short_text in text_get:
+ pywikibot.output(u"%s is already in the report page."
+ % image_to_report)
+ reported = False
+ elif len(text_get) >= self.logFulNumber:
if self.logFullError:
raise LogIsFull(
u"The log page (%s) is full! Please delete the old files "
@@ -1110,24 +1100,11 @@
# Don't report, but continue with the check
# (we don't now if this is the first time we check this file
# or not)
- return True
-
- # Skip if the message is already there.
- # Don't care for differences inside brackets.
- end = rep_text.find('(', max(0, rep_text.find(']]')))
- if end < 0:
- end = None
- short_text = rep_text[:end].strip()
- if short_text in text_get:
- pywikibot.output(u"%s is already in the report page."
- % image_to_report)
- reported = False
else:
# Adding the log
another_page.put(text_get + rep_text, summary=com, force=True,
minorEdit=False)
pywikibot.output(u"...Reported...")
- reported = True
return reported
def takesettings(self):
@@ -1343,7 +1320,7 @@
self.some_problem = False
else:
if not self.seems_ok and self.license_found:
- rep_text_license_fake = u"\n*[[:File:%s]] seems to have " \
+ rep_text_license_fake = u"\n* [[:File:%s]] seems to have " \
% self.imageName + \
"a ''fake license'', license detected: <nowiki>%s</nowiki>" \
% self.license_found
--
To view, visit https://gerrit.wikimedia.org/r/251695
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I46a29e6417b0ffe6abfeb9ee773c19f0af3f7323
Gerrit-PatchSet: 4
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: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Enable tabulators for json dump.
......................................................................
[IMPR] Enable tabulators for json dump.
In python >=3.2 json.dump allows strings for indent in addition to integers
but previous version does not. Use json.dumps and replace spaces with tabs.
Add an option to prevent pretty print of the dict.
Change-Id: I49d22cff2075dbbc36b21fc38a906b7dea504011
---
M scripts/maintenance/make_i18n_dict.py
1 file changed, 23 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/maintenance/make_i18n_dict.py b/scripts/maintenance/make_i18n_dict.py
index 639864a..5f2150b 100755
--- a/scripts/maintenance/make_i18n_dict.py
+++ b/scripts/maintenance/make_i18n_dict.py
@@ -107,16 +107,29 @@
if 'en' not in keys:
print('WARNING: "en" key missing for message %s' % newmsg)
- def run(self):
- """Run the bot, read the messages from source and print the dict."""
+ def run(self, quiet=False):
+ """
+ Run the bot, read the messages from source and print the dict.
+
+ @param quiet: print the result if False
+ @type quiet: bool
+ """
for item in self.messages.items():
self.read(*item)
- self.print_all()
+ if not quiet:
+ self.print_all()
- def to_json(self):
- """Run the bot and create json files."""
+ def to_json(self, quiet=True):
+ """
+ Run the bot and create json files.
+
+ @param quiet: Print the result if False
+ @type quiet: bool
+ """
+ IDENT = 4
+
if not self.dict:
- self.run()
+ self.run(quiet)
json_dir = os.path.join(
config.base_dir, 'scripts/i18n', self.scriptname)
if not os.path.exists(json_dir):
@@ -131,8 +144,10 @@
new_dict['@metadata'] = new_dict.get('@metadata', {'authors': []})
with codecs.open(file_name, 'w', 'utf-8') as json_file:
new_dict.update(self.dict[lang])
- json.dump(new_dict, json_file, ensure_ascii=False,
- sort_keys=True, indent=4, separators=(',', ': '))
+ s = json.dumps(new_dict, ensure_ascii=False, sort_keys=True,
+ indent=IDENT, separators=(',', ': '))
+ s = s.replace(' ' * IDENT, '\t')
+ json_file.write(s)
if __name__ == '__main__':
print(__doc__)
--
To view, visit https://gerrit.wikimedia.org/r/251837
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I49d22cff2075dbbc36b21fc38a906b7dea504011
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: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [IMPR] Don't raise KeyError in _params property.
......................................................................
[IMPR] Don't raise KeyError in _params property.
- Remove a kind of code duplication. A similar exception will be raised by
__missing__ method of the LogDict dictionary.
- Remove empty flags for unblock action.
Change-Id: I4a40cf543c716fb81126a67cfdc2f00bef201381
---
M pywikibot/logentries.py
1 file changed, 3 insertions(+), 5 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/logentries.py b/pywikibot/logentries.py
index 452bf9d..1b1c376 100644
--- a/pywikibot/logentries.py
+++ b/pywikibot/logentries.py
@@ -69,11 +69,7 @@
if 'params' in self.data:
return self.data['params']
else: # try old mw style preceding mw 1.19
- try:
- return self.data[self._expectedType]
- except KeyError:
- raise Error("action='%s': this log entry has no params details "
- "for type %s." % (self.action(), self.type))
+ return self.data[self._expectedType]
def logid(self):
"""Return the id of the log entry."""
@@ -177,6 +173,8 @@
@rtype: list of flag strings
"""
+ if self.action() == 'unblock':
+ return []
if not hasattr(self, '_flags'):
self._flags = self._params['flags']
# pre mw 1.19 returned a delimited string.
--
To view, visit https://gerrit.wikimedia.org/r/233218
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4a40cf543c716fb81126a67cfdc2f00bef201381
Gerrit-PatchSet: 2
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: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>