jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/337433 )
Change subject: [Bugfix] Fix variable assignment in handleOneLink ......................................................................
[Bugfix] Fix variable assignment in handleOneLink
Change-Id: I6e6dc467d5f9f9c2cd9a13f109af258e33465ff7 --- M pywikibot/cosmetic_changes.py M tests/cosmetic_changes_tests.py 2 files changed, 11 insertions(+), 10 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index 20fff17..2684d81 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -526,16 +526,15 @@ firstcase_title = titleWithSection firstcase_label = label
- if firstcase_label.startswith(firstcase_title): - if firstcase_label == firstcase_title: - newLink = '[[%s]]' % label - # Check if we can create a link with trailing characters - # instead of a pipelink - elif trailR.sub('', - label[len(titleWithSection):]) == '': - newLink = '[[%s]]%s' % ( - label[:len(titleWithSection)], - label[len(titleWithSection):]) + if firstcase_label == firstcase_title: + newLink = '[[%s]]' % label + # Check if we can create a link with trailing characters + # instead of a pipelink + elif (firstcase_label.startswith(firstcase_title) and + trailR.sub('', label[len(titleWithSection):]) == ''): + newLink = '[[%s]]%s' % ( + label[:len(titleWithSection)], + label[len(titleWithSection):])
else: # Try to capitalize the first letter of the title. diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py index b5ef83e..6a7112d 100644 --- a/tests/cosmetic_changes_tests.py +++ b/tests/cosmetic_changes_tests.py @@ -247,6 +247,8 @@
def test_cleanUpLinks_pipes(self): """Test cleanUpLinks method.""" + self.assertEqual('[[no|no change]]', + self.cct.cleanUpLinks('[[no|no change]]')) self.assertEqual('[[title]]', self.cct.cleanUpLinks('[[title|title]]')) self.assertEqual('[[title]]',
pywikibot-commits@lists.wikimedia.org