jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509395 )
Change subject: [L10N] Add testwiki and improve errors in clean_sandbox.py
......................................................................
[L10N] Add testwiki and improve errors in clean_sandbox.py
- Merge pywikibot.error with raise as the error message can be overlooked
- Remove traceback for missing generator
Bug: T217054
Change-Id: I5f5b83e9ed6ee7186eee7463e76cceb2770c846f
---
M scripts/clean_sandbox.py
1 file changed, 6 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index ecc9d2b..36c27f7 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -38,6 +38,7 @@
from __future__ import absolute_import, division, unicode_literals
import datetime
+import sys
import time
import pywikibot
@@ -46,6 +47,8 @@
content = {
'commons': '{{Sandbox}}\n<!-- Please edit only below this line. -->',
+ 'test': '<noinclude>{{Sandbox}}</noinclude>\n'
+ '== Please start your testing below this line ==',
'wikidata': '{{Please leave this line alone (sandbox heading)}}',
'wikivoyage': {
'es': '<!--No borres este mensaje-->'
@@ -155,8 +158,8 @@
self.translated_content = self.getOption('text') or i18n.translate(
self.site, content)
if not self.translated_content:
- pywikibot.error('No content is given for pages, exiting.')
- raise RuntimeError
+ raise RuntimeError(
+ 'No content is given for sandbox pages, exiting.')
if not self.generator:
pages = []
for item in sandbox_titles:
@@ -165,7 +168,7 @@
pages.append(p)
if not pages:
pywikibot.bot.suggest_help(missing_generator=True)
- raise RuntimeError
+ sys.exit()
self.generator = pages
def run(self):
--
To view, visit https://gerrit.wikimedia.org/r/509395
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I5f5b83e9ed6ee7186eee7463e76cceb2770c846f
Gerrit-Change-Number: 509395
Gerrit-PatchSet: 1
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509369 )
Change subject: [tests] Add fake-useragent and browseragents to extras
......................................................................
[tests] Add fake-useragent and browseragents to extras
- This will enable some always skipped tests on Travis
Change-Id: I7c84eedc52cc9888f0b20959c7b28f9cbcd17dbf
---
M setup.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index e218e90..bb55c02 100644
--- a/setup.py
+++ b/setup.py
@@ -57,6 +57,7 @@
'security': ['requests[security]', 'pycparser!=2.14'],
'mwoauth': ['mwoauth>=0.2.4,!=0.3.1'],
'html': ['BeautifulSoup4'],
+ 'http': ['browseragents', 'fake_useragent'],
'flake8': [ # Due to incompatibilities between packages the order matters.
'flake8>=3.7.5',
pydocstyle,
--
To view, visit https://gerrit.wikimedia.org/r/509369
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7c84eedc52cc9888f0b20959c7b28f9cbcd17dbf
Gerrit-Change-Number: 509369
Gerrit-PatchSet: 3
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509366 )
Change subject: [L10N] Add testwiki and improve l10n errors in checkimages.py
......................................................................
[L10N] Add testwiki and improve l10n errors in checkimages.py
Bug: T217054
Change-Id: Ifb2f7fe7603998c4507e72168f780afa4c38412f
---
M scripts/checkimages.py
1 file changed, 33 insertions(+), 9 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 8e0bda5..10b132c 100755
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -112,6 +112,7 @@
n_txt = {
'commons': '{{subst:nld}}',
'meta': '{{No license}}',
+ 'test': '{{No license}}',
'ar': '{{subst:لم}}',
'de': '{{Dateiüberprüfung}}',
'en': '{{subst:nld}}',
@@ -139,6 +140,7 @@
'commons': ['{{no license', '{{no license/en',
'{{nld', '{{no permission', '{{no permission since'],
'meta': ['{{no license', '{{nolicense', '{{nld'],
+ 'test': ['{{no license'],
'ar': ['{{لت', '{{لا ترخيص'],
'de': ['{{DÜP', '{{Düp', '{{Dateiüberprüfung'],
'en': ['{{nld', '{{no license'],
@@ -346,6 +348,7 @@
report_page = {
'commons': 'User:Filbot/Report',
'meta': 'User:MABot/Report',
+ 'test': 'User:Pywikibot-test/Report',
'de': 'Benutzer:Xqbot/Report',
'en': 'User:Filnik/Report',
'fa': 'کاربر:Amirobot/گزارش تصویر',
@@ -391,6 +394,7 @@
# Put the other in the page on the project defined below
'commons': ['Template:Information'],
'meta': ['Template:Information'],
+ 'test': ['Template:Information'],
'ar': ['Template:معلومات'],
'de': ['Template:Information'],
'en': ['Template:Information'],
@@ -504,6 +508,7 @@
category_with_licenses = {
'commons': 'Category:License tags',
'meta': 'Category:License templates',
+ 'test': 'Category:CC license tags',
'ar': 'تصنيف:قوالب حقوق الصور',
'de': 'Kategorie:Vorlage:Lizenz für Bilder',
'en': 'Category:Wikipedia file copyright templates',
@@ -546,7 +551,7 @@
# Add your project (in alphabetical order) if you want that the bot starts
project_inserted = ['ar', 'commons', 'de', 'en', 'fa', 'ga', 'hu', 'it', 'ja',
- 'ko', 'meta', 'sr', 'ta', 'ur', 'zh']
+ 'ko', 'meta', 'sr', 'ta', 'test', 'ur', 'zh']
# END OF CONFIGURATION.
@@ -585,10 +590,18 @@
self.logFullError = logFullError
self.logFulNumber = logFulNumber
self.rep_page = i18n.translate(self.site, report_page)
+ if not self.rep_page:
+ raise i18n.TranslationError(
+ 'No report page provided in "report_page" dict '
+ 'for your project!')
self.image_namespace = site.namespaces.FILE.custom_name + ':'
self.list_entry = '\n* [[:{0}%s]] '.format(self.image_namespace)
self.com = i18n.translate(self.site, msg_comm10, fallback=True)
hiddentemplatesRaw = i18n.translate(self.site, HiddenTemplate)
+ if not hiddentemplatesRaw:
+ raise i18n.TranslationError(
+ 'No non-license templates provided in "HiddenTemplate" dict '
+ 'for your project!')
self.hiddentemplates = {
pywikibot.Page(self.site, tmp, ns=self.site.namespaces.TEMPLATE)
for tmp in hiddentemplatesRaw}
@@ -628,6 +641,10 @@
"""Function to make the reports easier."""
self.image_to_report = image_to_report
self.newtext = newtext
+ if not newtext:
+ raise i18n.TranslationError(
+ 'No no-license template provided in "n_txt" dict '
+ 'for your project!')
self.head = head or ''
self.notification = notification
self.notification2 = notification2
@@ -1168,9 +1185,9 @@
"""Load the list of the licenses."""
catName = i18n.translate(self.site, category_with_licenses)
if not catName:
- raise pywikibot.Error(
- 'No licenses allowed provided, add that option to the code to '
- 'make the script working correctly')
+ raise i18n.TranslationError(
+ 'No allowed licenses category provided in '
+ '"category_with_licenses" dict for your project!')
pywikibot.output('\nLoading the allowed licenses...\n')
cat = pywikibot.Category(self.site, catName)
list_licenses = list(cat.articles())
@@ -1271,9 +1288,9 @@
self.allLicenses = []
if not self.list_licenses:
- raise pywikibot.Error(
- 'No licenses allowed provided, add that option to the '
- 'code to make the script working correctly')
+ raise i18n.TranslationError(
+ 'No allowed licenses found in "category_with_licenses" '
+ 'category for your project!')
# Found the templates ONLY in the image's description
for template_selected in templatesInTheImageRaw:
@@ -1413,7 +1430,12 @@
"""Understand if a file is already tagged or not."""
# TODO: enhance and use textlib._MultiTemplateMatchBuilder
# Is the image already tagged? If yes, no need to double-check, skip
- for i in i18n.translate(self.site, txt_find):
+ no_license = i18n.translate(self.site, txt_find)
+ if not no_license:
+ raise i18n.TranslationError(
+ 'No no-license templates provided in "txt_find" dict '
+ 'for your project!')
+ for i in no_license:
# If there are {{ use regex, otherwise no (if there's not the
# {{ may not be a template and the regex will be wrong)
if '{{' in i:
@@ -1736,7 +1758,9 @@
# en-parameters
if site.code not in project_inserted:
pywikibot.output('Your project is not supported by this script.\n'
- 'You have to edit the script and add it!')
+ 'To allow your project in the script you have to '
+ 'add a localization into the script and add your '
+ 'project to the "project_inserted" list!')
return False
# Reading the log of the new images if another generator is not given.
--
To view, visit https://gerrit.wikimedia.org/r/509366
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifb2f7fe7603998c4507e72168f780afa4c38412f
Gerrit-Change-Number: 509366
Gerrit-PatchSet: 1
Gerrit-Owner: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/496801 )
Change subject: [IMPR] Remove '.py' before matching the string
......................................................................
[IMPR] Remove '.py' before matching the string
- Improve string matching by removing '.py' ending.
See T217195 for further information.
- Also ignore __init__.py scripts
- use set to hold the script names to hold the script path
(used later to let the user the choice to start it)
Bug: T217195
Change-Id: I3952cb77191890cface75bdb5a51e7c2613f63ac
---
M pwb.py
1 file changed, 11 insertions(+), 10 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pwb.py b/pwb.py
index 9027c8c..164d44c 100755
--- a/pwb.py
+++ b/pwb.py
@@ -196,22 +196,23 @@
print('ERROR: {} not found! Misspelling?'.format(filename),
file=sys.stderr)
- scripts = []
+ scripts = {}
for file_package in script_paths:
path = file_package.split('.')
for script_name in os.listdir(os.path.join(*path)):
- if script_name.endswith('.py'):
- scripts.append(script_name)
+ if (script_name.endswith('.py')
+ and not script_name.startswith('__')):
+ # remove .py for better matching
+ scripts[script_name[:-3]] = os.path.join(
+ *(path + [script_name]))
- similar_scripts = get_close_matches(filename, scripts,
+ similar_scripts = get_close_matches(filename[:-3], scripts,
n=10, cutoff=0.7)
-
if similar_scripts:
- print(
- '\nThe most similar {}:'
- .format('script is' if len(similar_scripts) == 1
- else 'scripts are'))
- print('\t' + '\n\t'.join(similar_scripts))
+ print('\nThe most similar script{}:'
+ .format(' is' if len(similar_scripts) == 1
+ else 's are'))
+ print('\t' + '.py\n\t'.join(similar_scripts) + '.py')
return True
# When both pwb.py and the filename to run are within the current
--
To view, visit https://gerrit.wikimedia.org/r/496801
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I3952cb77191890cface75bdb5a51e7c2613f63ac
Gerrit-Change-Number: 496801
Gerrit-PatchSet: 8
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/509061 )
Change subject: use "streams" instead of "stream" for creating EventStreams instance
......................................................................
use "streams" instead of "stream" for creating EventStreams instance
EventStreams can have multiple streams. Therefore the parameter "stream"
was renamed to "streams" and "stream" is deprecated.
Replace the parameter in site_rc_listener
Change-Id: I49d9b5134824411a4cb02a45166725b40244d4ad
---
M pywikibot/comms/eventstreams.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index 710bebd..690b4d7 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -344,7 +344,7 @@
raise ImportError('sseclient is required for EventStreams;\n'
'install it with "pip install sseclient"\n')
- stream = EventStreams(stream='recentchange', site=site)
+ stream = EventStreams(streams='recentchange', site=site)
stream.set_maximum_items(total)
stream.register_filter(server_name=site.hostname())
return stream
--
To view, visit https://gerrit.wikimedia.org/r/509061
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I49d9b5134824411a4cb02a45166725b40244d4ad
Gerrit-Change-Number: 509061
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)