mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Make utils.str.perlRoToReplacer less ambiguous.
This commit is contained in:
parent
8af6761275
commit
452c706092
@ -45,7 +45,6 @@ from structures import TwoWayDictionary
|
|||||||
from supybot.i18n import PluginInternationalization
|
from supybot.i18n import PluginInternationalization
|
||||||
internationalizeFunction=PluginInternationalization().internationalizeFunction
|
internationalizeFunction=PluginInternationalization().internationalizeFunction
|
||||||
|
|
||||||
curry = new.instancemethod
|
|
||||||
chars = string.maketrans('', '')
|
chars = string.maketrans('', '')
|
||||||
|
|
||||||
def rsplit(s, sep=None, maxsplit=-1):
|
def rsplit(s, sep=None, maxsplit=-1):
|
||||||
@ -195,9 +194,11 @@ def perlReToReplacer(s):
|
|||||||
if 'g' in flags:
|
if 'g' in flags:
|
||||||
g = True
|
g = True
|
||||||
flags = filter('g'.__ne__, flags)
|
flags = filter('g'.__ne__, flags)
|
||||||
|
if isinstance(flags, list):
|
||||||
|
flags = ''.join(flags)
|
||||||
r = perlReToPythonRe(sep.join(('', regexp, flags)))
|
r = perlReToPythonRe(sep.join(('', regexp, flags)))
|
||||||
if g:
|
if g:
|
||||||
return curry(r.sub, replace)
|
return lambda s: r.sub(replace, s)
|
||||||
else:
|
else:
|
||||||
return lambda s: r.sub(replace, s, 1)
|
return lambda s: r.sub(replace, s, 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user