[MediaWiki-commits] [Gerrit] pywikibot/core[master]: [bugfix][TEST] cc: Get cleanUpSectionHeaders working with tabs

2018-01-23 Thread jenkins-bot (Code Review)
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[^=]+?) *\1 *\r?\n',
+r'(?m)^(={1,6})[ \t]*(?P.*[^\s=])[ \t]*\1[ \t]*\r?\n',
 r'\1 \g \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('Fo bar',
- self.cct.removeUselessSpaces('Fo bar  '))
+ self.cct.removeUselessSpaces('Fo 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 
Gerrit-Reviewer: Dalba 
Gerrit-Reviewer: Dvorapa 
Gerrit-Reviewer: Framawiki 
Gerrit-Reviewer: John Vandenberg 
Gerrit-Reviewer: Magul 
Gerrit-Reviewer: TerraCodes 
Gerrit-Reviewer: Thiemo Kreuz (WMDE) 
Gerrit-Reviewer: Xqt 
Gerrit-Reviewer: Zoranzoki21 
Gerrit-Reviewer: jenkins-bot <>

___
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

2018-01-20 Thread Dvorapa (Code Review)
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[^=]+?) *\1 *\r?\n',
+r'(?m)^(={1,7}) *(?P[^=]+?) *\1[ \t]*\r?\n',
 r'\1 \g \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 

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