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 <>