jenkins-bot has submitted this change and it was merged.
Change subject: Changes are wrongly detected in the last langlink
......................................................................
Changes are wrongly detected in the last langlink
This was first detected in cosmetic_changes.py, where pages not needing any
cosmetic changes were still being updated, and the supposed changed was an
unchanged langlink (the last one). Then I realized this also happens in
interwiki.py, but only when changes are supposed to be made to the page.
After checking textlib.py, I noticed that removeLanguageLinks() returns a
stripped version of the text whereas replaceLanguageLinks() does not. So
the actual difference is related to blank space.
This explains why cosmetic_changes.py detects a change and updates the page,
but interwiki.py does not: interwiki.py does not rely in differences in the
final text to make an update, but when it does need to make an update, it
outputs that diff.
This patch strips the text in replaceLanguageLinks() before returning if the
original text is stripped itself.
Conflicts:
pywikibot/textlib.py
Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
(manually cherry picked from 097245e7e34)
---
M pywikibot/textlib.py
1 file changed, 8 insertions(+), 2 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index b40aba4..42a9e62 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -31,7 +31,10 @@
from pywikibot import config2 as config
from pywikibot.family import Family
-from pywikibot.tools import OrderedDict
+from pywikibot.tools import (
+ OrderedDict,
+ issue_deprecation_warning
+)
# cache for replaceExcept to avoid recompile or regexes each call
_regex_cache = {}
@@ -595,6 +598,9 @@
cseparator = site.family.category_text_separator
separatorstripped = separator.strip()
cseparatorstripped = cseparator.strip()
+ do_not_strip = oldtext.strip() != oldtext
+ if do_not_strip:
+ issue_deprecation_warning('Using unstripped text', 'stripped
text', 2)
if addOnly:
s2 = oldtext
else:
@@ -662,7 +668,7 @@
newtext = s2.replace(marker, '').strip() + separator + s
else:
newtext = s2.replace(marker, '')
- return newtext
+ return newtext if do_not_strip else newtext.strip()
def interwikiFormat(links, insite=None):
--
To view, visit
https://gerrit.wikimedia.org/r/243514
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Icd7252be8dbccf3fb04a4b4a465f6b057e3a8e3a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Malafaya <malafaya(a)clix.pt>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>