Mailing List Archive

[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs
Dvorapa has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/405539 )

Change subject: [bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs
......................................................................

[bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs

Bug: T185392
Change-Id: I0bafdf3db015d3bca7622219085307d524b51ee7
---
M pywikibot/cosmetic_changes.py
M tests/cosmetic_changes_tests.py
2 files changed, 4 insertions(+), 1 deletion(-)


git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/39/405539/1

diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 009eed5..d957dd4 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -649,7 +649,7 @@
return text
return textlib.replaceExcept(
text,
- r'(?m)^(={1,7}) *(?P<title>[^=]+?) *\1 *\r?\n',
+ r'(?m)^(={1,7}) *(?P<title>[^=]+?) *\1[ \t]*\r?\n',
r'\1 \g<title> \1%s' % config.LS,
['comment', 'math', 'nowiki', 'pre'])

diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py
index 6e22088..6474627 100644
--- a/tests/cosmetic_changes_tests.py
+++ b/tests/cosmetic_changes_tests.py
@@ -83,6 +83,9 @@
"""Test cleanUpSectionHeaders method."""
self.assertEqual('=== Header ===\n',
self.cct.cleanUpSectionHeaders('===Header===\n'))
+ # tab
+ self.assertEqual('=== Header ===\n',
+ self.cct.cleanUpSectionHeaders('===Header=== \n'))

def test_putSpacesInLists(self):
"""Test putSpacesInLists method."""

--
To view, visit https://gerrit.wikimedia.org/r/405539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0bafdf3db015d3bca7622219085307d524b51ee7
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dvorapa <dvorapa@seznam.cz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs [ In reply to ]
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/405539 )

Change subject: [bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs
......................................................................


[bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs

+ limit heading level to MediaWiki's maximum of 6
+ fix regex for headings containing equal sign
+ replace actual tab character in tests by escape sequence

Bug: T185392
Change-Id: I0bafdf3db015d3bca7622219085307d524b51ee7
---
M pywikibot/cosmetic_changes.py
M tests/cosmetic_changes_tests.py
2 files changed, 8 insertions(+), 2 deletions(-)

Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified



diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 009eed5..a3dee44 100755
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -649,7 +649,7 @@
return text
return textlib.replaceExcept(
text,
- r'(?m)^(={1,7}) *(?P<title>[^=]+?) *\1 *\r?\n',
+ r'(?m)^(={1,6})[ \t]*(?P<title>.*[^\s=])[ \t]*\1[ \t]*\r?\n',
r'\1 \g<title> \1%s' % config.LS,
['comment', 'math', 'nowiki', 'pre'])

diff --git a/tests/cosmetic_changes_tests.py b/tests/cosmetic_changes_tests.py
index 6e22088..64c6a34 100644
--- a/tests/cosmetic_changes_tests.py
+++ b/tests/cosmetic_changes_tests.py
@@ -72,7 +72,7 @@
self.cct.removeUselessSpaces(' Foo bar '))
# tab
self.assertEqual('Fooooo bar',
- self.cct.removeUselessSpaces('Fooooo bar '))
+ self.cct.removeUselessSpaces('Fooooo bar\t'))

def test_removeNonBreakingSpaceBeforePercent(self):
"""Test removeNonBreakingSpaceBeforePercent method."""
@@ -83,6 +83,12 @@
"""Test cleanUpSectionHeaders method."""
self.assertEqual('=== Header ===\n',
self.cct.cleanUpSectionHeaders('===Header===\n'))
+ # tab
+ self.assertEqual('=== Header ===\n',
+ self.cct.cleanUpSectionHeaders('===Header===\t\n'))
+ # tabs inside
+ self.assertEqual('=== Header ===\n',
+ self.cct.cleanUpSectionHeaders('===\tHeader\t===\n'))

def test_putSpacesInLists(self):
"""Test putSpacesInLists method."""

--
To view, visit https://gerrit.wikimedia.org/r/405539
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0bafdf3db015d3bca7622219085307d524b51ee7
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Dalba <dalba.wiki@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki@tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb@gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski@gmail.com>
Gerrit-Reviewer: TerraCodes <terracodes@tools.wmflabs.org>
Gerrit-Reviewer: Thiemo Kreuz (WMDE) <thiemo.kreuz@wikimedia.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits