1 |
commit: 6917ef66abadfc957da41d69a7dd63289bf4014f |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Nov 18 05:33:37 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Nov 18 05:33:37 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6917ef66 |
7 |
|
8 |
_make_msgfunction: convert to class |
9 |
|
10 |
--- |
11 |
pym/portage/elog/messages.py | 16 ++++++++++------ |
12 |
1 files changed, 10 insertions(+), 6 deletions(-) |
13 |
|
14 |
diff --git a/pym/portage/elog/messages.py b/pym/portage/elog/messages.py |
15 |
index 98d6206..ba2ed46 100644 |
16 |
--- a/pym/portage/elog/messages.py |
17 |
+++ b/pym/portage/elog/messages.py |
18 |
@@ -172,13 +172,17 @@ _functions = { "einfo": ("INFO", "GOOD"), |
19 |
"eerror": ("ERROR", "BAD"), |
20 |
} |
21 |
|
22 |
-def _make_msgfunction(level, color): |
23 |
- def _elog(msg, phase="other", key=None, out=None): |
24 |
- """ Display and log a message assigned to the given key/cpv |
25 |
- (or unassigned if no key is given). |
26 |
+class _make_msgfunction(object): |
27 |
+ __slots__ = ('_color', '_level') |
28 |
+ def __init__(self, level, color): |
29 |
+ self._level = level |
30 |
+ self._color = color |
31 |
+ def __call__(self, msg, phase="other", key=None, out=None): |
32 |
+ """ |
33 |
+ Display and log a message assigned to the given key/cpv. |
34 |
""" |
35 |
- _elog_base(level, msg, phase=phase, key=key, color=color, out=out) |
36 |
- return _elog |
37 |
+ _elog_base(self._level, msg, phase=phase, |
38 |
+ key=key, color=self._color, out=out) |
39 |
|
40 |
for f in _functions: |
41 |
setattr(sys.modules[__name__], f, _make_msgfunction(_functions[f][0], _functions[f][1])) |