jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/351928 )
Change subject: Replace private mylang variables with mycode in generate_user_files.py
......................................................................
Replace private mylang variables with mycode in generate_user_files.py
site.code is the identifying code of a site presumed to be equal to the
wiki prefix whereas site language is the ISO language code for a site.
e.g. 'als' is a site code whereas its site language is 'gsw'
'meta' is a site code whereas its language is 'en'
local variable should follow this difference
Change-Id: I91d06c919b1b0e25c1538a1f6f4e6f86f7b0fb22
---
M generate_user_files.py
1 file changed, 16 insertions(+), 16 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index 74837a1..930eeb3 100755
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -142,22 +142,22 @@
default_lang = None
message = "The language code of the site we're working on"
- mylang = None
- while not mylang:
- mylang = pywikibot.input(message, default=default_lang, force=force)
- if known_langs and mylang and mylang not in known_langs:
+ mycode = None
+ while not mycode:
+ mycode = pywikibot.input(message, default=default_lang, force=force)
+ if known_langs and mycode and mycode not in known_langs:
if not pywikibot.input_yn("The language code {0} is not in the "
"list of known languages. Do you want "
- "to continue?".format(mylang),
+ "to continue?".format(mycode),
default=False, automatic_quit=False):
- mylang = None
+ mycode = None
- message = u"Username on {0}:{1}".format(mylang, fam.name)
+ message = 'Username on {0}:{1}'.format(mycode, fam.name)
username = pywikibot.input(message, default=default_username, force=force)
# Escape ''s
if username:
username = username.replace("'", "\\'")
- return fam.name, mylang, username
+ return fam.name, mycode, username
EXTENDED_CONFIG = """# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
@@ -196,7 +196,7 @@
family = '{main_family}'
# The language code of the site we're working on.
-mylang = '{main_lang}'
+mylang = '{main_code}'
# The dictionary usernames should contain a username for each site where you
# have a bot account. If you have a unique username for all languages of a
@@ -209,7 +209,7 @@
SMALL_CONFIG = ('# -*- coding: utf-8 -*-\n'
u"from __future__ import absolute_import, unicode_literals\n"
u"family = '{main_family}'\n"
- u"mylang = '{main_lang}'\n"
+ "mylang = '{main_code}'\n"
u"{usernames}\n")
@@ -221,22 +221,22 @@
if args and force and not config.verbose_output:
# main_username may be None, which is used in the next block
- main_family, main_lang, main_username = args
+ main_family, main_code, main_username = args
usernames = [args]
else:
- main_family, main_lang, main_username = get_site_and_lang(*args,
+ main_family, main_code, main_username = get_site_and_lang(*args,
force=force)
- usernames = [(main_family, main_lang, main_username)]
+ usernames = [(main_family, main_code, main_username)]
while pywikibot.input_yn("Do you want to add any other projects?",
force=force,
default=False, automatic_quit=False):
- usernames += [get_site_and_lang(main_family, main_lang,
+ usernames += [get_site_and_lang(main_family, main_code,
main_username)]
if not main_username:
usernames = "# usernames['{0}']['{1}'] = u'MyUsername'".format(
- main_family, main_lang)
+ main_family, main_code)
else:
usernames = '\n'.join(
u"usernames['{0}']['{1}'] = u'{2}'".format(*username)
@@ -289,7 +289,7 @@
try:
with codecs.open(_fnc, "w", "utf-8") as f:
f.write(config_content.format(main_family=main_family,
- main_lang=main_lang,
+ main_code=main_code,
usernames=usernames,
config_text=config_text))
--
To view, visit https://gerrit.wikimedia.org/r/351928
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I91d06c919b1b0e25c1538a1f6f4e6f86f7b0fb22
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/300744 )
Change subject: replace.py: allow to edit modified text
......................................................................
replace.py: allow to edit modified text
Allow to edit the latest version (i.e., with modifications) of the text.
This allows to make changes without further replacements being applied.
It is useful to make changes that should not be caught by replacements
or to amend unwanted fixes in complex replacement cases.
Change-Id: I32c46820117415ee337844d17556accfae746a79
---
M scripts/replace.py
1 file changed, 11 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/replace.py b/scripts/replace.py
index 7b5c952..77d1878 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -733,13 +733,13 @@
continue
applied = set()
new_text = original_text
+ last_text = None
while True:
if self.isTextExcepted(new_text):
pywikibot.output(u'Skipping %s because it contains text '
u'that is on the exceptions list.'
% page.title(asLink=True))
break
- last_text = None
while new_text != last_text:
last_text = new_text
new_text = self.apply_replacements(last_text, applied,
@@ -768,7 +768,7 @@
break
choice = pywikibot.input_choice(
u'Do you want to accept these changes?',
- [('Yes', 'y'), ('No', 'n'), ('Edit', 'e'),
+ [('Yes', 'y'), ('No', 'n'), ('Edit original', 'e'), ('edit Latest', 'l'),
('open in Browser', 'b'), ('all', 'a')],
default='N')
if choice == 'e':
@@ -777,6 +777,14 @@
# if user didn't press Cancel
if as_edited and as_edited != new_text:
new_text = as_edited
+ continue
+ if choice == 'l':
+ editor = editarticle.TextEditor()
+ as_edited = editor.edit(new_text)
+ # if user didn't press Cancel
+ if as_edited and as_edited != new_text:
+ new_text = as_edited
+ last_text = new_text # prevent changes from being applied again
continue
if choice == 'b':
pywikibot.bot.open_webbrowser(page)
@@ -787,6 +795,7 @@
% page.title())
break
new_text = original_text
+ last_text = None
continue
if choice == 'a':
self.options['always'] = True
--
To view, visit https://gerrit.wikimedia.org/r/300744
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I32c46820117415ee337844d17556accfae746a79
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/257537 )
Change subject: Add flake8-diff tox env for names and quotes
......................................................................
Add flake8-diff tox env for names and quotes
flake8-diff can be used to highlight potential code style issues
in modified lines, but can not be voting against patches due to
high number of undesirable reported problems.
Change-Id: I993886870e44d06dd8df882bb205cecb4c841f54
---
M tox.ini
1 file changed, 13 insertions(+), 0 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index ac5a94b..a75d076 100644
--- a/tox.ini
+++ b/tox.ini
@@ -45,6 +45,19 @@
flake8-docstrings<0.2.2
flake8-putty
+# 4a226d07 is https://github.com/erikrose/blessings/pull/104
+[testenv:flake8-diff]
+commands =
+ flake8 --version
+ flake8-diff --flake8-options --ignore={[flake8]ignore} {posargs}
+deps = flake8-diff
+ https://github.com/erikrose/blessings/archive/4a226d07.zip
+ flake8-docstrings<0.2.2
+ flake8-putty
+ pep8-naming
+ flake8-quotes
+ flake8-blind-except
+
[testenv:nose]
commands =
python -W error::UserWarning -m generate_user_files -family:test -lang:test -v
--
To view, visit https://gerrit.wikimedia.org/r/257537
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I993886870e44d06dd8df882bb205cecb4c841f54
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: 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. ( https://gerrit.wikimedia.org/r/333033 )
Change subject: [bugfix] Manage temporary readonly error
......................................................................
[bugfix] Manage temporary readonly error
It's look like the API error named internal_api_error_ReadOnlyError was renamed to readonly. So, code.startswith(u'internal_api_error_') is not enabled. I've edited the code to accept readonly as an error that need edit retry. Need investigation to verify if internal_api_error_ReadOnlyError is still enabled, and if others error codes are impacted.
Bug: T154011
Change-Id: I9cc80c77532db3d9b71db5c33f91b8a699f41d6c
---
M pywikibot/data/api.py
1 file changed, 10 insertions(+), 3 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index e704023..9a1a585 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -2089,15 +2089,22 @@
pywikibot.warning('API error %s: %s' % (code, info))
- if code.startswith(u'internal_api_error_'):
- class_name = code[len(u'internal_api_error_'):]
+ if code.startswith('internal_api_error_') or code == 'readonly':
+ if code == 'readonly': # T154011
+ class_name = code
+ else:
+ class_name = code[len(u'internal_api_error_'):]
del error['code'] # is added via class_name
e = APIMWException(class_name, **error)
+ # If the error key is in this table, it is probably a temporary problem,
+ # so we will retry the edit.
+ # TODO: T154011: 'ReadOnlyError' seems replaced by 'readonly'
retry = class_name in ['DBConnectionError', # T64974
'DBQueryError', # T60158
- 'ReadOnlyError' # T61227
+ 'ReadOnlyError', # T61227
+ 'readonly', # T154011
]
pywikibot.error("Detected MediaWiki API exception %s%s"
--
To view, visit https://gerrit.wikimedia.org/r/333033
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9cc80c77532db3d9b71db5c33f91b8a699f41d6c
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>