jenkins-bot has submitted this change and it was merged.
Change subject: casechecker.py: replace xuniqueCombinations with library functions ......................................................................
casechecker.py: replace xuniqueCombinations with library functions
Replace xuniqueCombinations() with itertools.combinations().
Change-Id: Ifb31aa0963e1edb1d6fc735882d5d9fe43b5b6c3 --- M scripts/casechecker.py 1 file changed, 3 insertions(+), 18 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/casechecker.py b/scripts/casechecker.py index 06ee014..30f4c8c 100755 --- a/scripts/casechecker.py +++ b/scripts/casechecker.py @@ -10,6 +10,7 @@ __version__ = '$Id$'
import codecs +import itertools import os import re from string import ascii_letters @@ -27,22 +28,6 @@ if sys.version_info[0] > 2: xrange = range
- -# -# Permutations code was taken from -# https://code.activestate.com/recipes/190465/ -# -def xuniqueCombinations(items, n): - if n == 0: - yield [] - else: - for i in xrange(len(items)): - for cc in xuniqueCombinations(items[i + 1:], n - 1): - yield [items[i]] + cc -# End of permutation code -# - -# # Windows Concole colors # This code makes this script Windows ONLY!!! # Feel free to adapt it to another platform @@ -609,8 +594,8 @@ # latin character. for itemCntToPick in xrange(0, len(ambigBadWords) + 1): title2 = title - for uc in xuniqueCombinations(list(ambigBadWords), - itemCntToPick): + for uc in itertools.combinations(list(ambigBadWords), + itemCntToPick): wordsToLat = ambigBadWords.copy() for bw in uc: title2 = title2.replace(bw, mapLcl[bw])
pywikibot-commits@lists.wikimedia.org