mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Added curry to fix.py, converted some code to use it.
This commit is contained in:
parent
c1e9205545
commit
93f02aa959
@ -36,11 +36,14 @@ Fixes stuff that Python should have but doesn't.
|
|||||||
__all__ = []
|
__all__ = []
|
||||||
|
|
||||||
exported = ['ignore', 'catch', 'reviter', 'window', 'group',
|
exported = ['ignore', 'catch', 'reviter', 'window', 'group',
|
||||||
'partition', 'any', 'all', 'rsplit']
|
'partition', 'any', 'all', 'rsplit', 'curry']
|
||||||
|
|
||||||
|
import new
|
||||||
import string
|
import string
|
||||||
string.ascii = string.maketrans('', '')
|
string.ascii = string.maketrans('', '')
|
||||||
|
|
||||||
|
curry = new.instancemethod
|
||||||
|
|
||||||
def ignore(*args, **kwargs):
|
def ignore(*args, **kwargs):
|
||||||
"""Simply ignore the arguments sent to it."""
|
"""Simply ignore the arguments sent to it."""
|
||||||
pass
|
pass
|
||||||
|
@ -249,7 +249,7 @@ class IrcState(IrcCommandDispatcher):
|
|||||||
self.nicksToHostmasks = ircutils.IrcDict()
|
self.nicksToHostmasks = ircutils.IrcDict()
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return map(lambda name: getattr(self, name), self.__slots__)
|
return map(curry(getattr, self), self.__slots__)
|
||||||
|
|
||||||
def __setstate__(self, t):
|
def __setstate__(self, t):
|
||||||
for (name, value) in zip(self.__slots__, t):
|
for (name, value) in zip(self.__slots__, t):
|
||||||
|
@ -235,7 +235,7 @@ def perlReToReplacer(s):
|
|||||||
flags = filter('g'.__ne__, flags)
|
flags = filter('g'.__ne__, flags)
|
||||||
r = perlReToPythonRe('/'.join(('', regexp, flags)))
|
r = perlReToPythonRe('/'.join(('', regexp, flags)))
|
||||||
if g:
|
if g:
|
||||||
return lambda s: r.sub(replace, s)
|
return curry(r.sub, replace)
|
||||||
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