Eranroz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/100333


Change subject: Allow empty match replace
......................................................................

Allow empty match replace

The patch fix a problem with empty matched group that encountered in replacebot 
used in hewiki.
Sometimes we want to match empty groups
eg /wiki(.?)pedia/ and replace to viki\1pedia

Change-Id: I58dd59a884b1be3c67627a5f4af7acc036c98699
---
M pywikibot/textlib.py
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/33/100333/1

diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index ffa7520..364b38d 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -232,7 +232,7 @@
                                int(groupMatch.group('number')))
                     try:
                         replacement = (replacement[:groupMatch.start()] +
-                                       match.group(groupID) + \
+                                       ('' if match.group(groupID)==None else 
match.group(groupID)) + \
                                        replacement[groupMatch.end():])
                     except IndexError:
                         pywikibot.output('\nInvalid group reference: %s' % 
groupID)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I58dd59a884b1be3c67627a5f4af7acc036c98699
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Eranroz <eranro...@gmail.com>

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

Reply via email to