From: Zac Medico Date: Fri, 18 Nov 2011 05:33:37 +0000 (-0800) Subject: _make_msgfunction: convert to class X-Git-Tag: v2.2.0_alpha76~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6917ef66abadfc957da41d69a7dd63289bf4014f;p=portage.git _make_msgfunction: convert to class --- diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py index 98d6206d0..ba2ed466b 100644 --- a/pym/portage/elog/messages.py +++ b/pym/portage/elog/messages.py @@ -172,13 +172,17 @@ _functions = { "einfo": ("INFO", "GOOD"), "eerror": ("ERROR", "BAD"), } -def _make_msgfunction(level, color): - def _elog(msg, phase="other", key=None, out=None): - """ Display and log a message assigned to the given key/cpv - (or unassigned if no key is given). +class _make_msgfunction(object): + __slots__ = ('_color', '_level') + def __init__(self, level, color): + self._level = level + self._color = color + def __call__(self, msg, phase="other", key=None, out=None): + """ + Display and log a message assigned to the given key/cpv. """ - _elog_base(level, msg, phase=phase, key=key, color=color, out=out) - return _elog + _elog_base(self._level, msg, phase=phase, + key=key, color=self._color, out=out) for f in _functions: setattr(sys.modules[__name__], f, _make_msgfunction(_functions[f][0], _functions[f][1]))