diff options
author | Zac Medico <zmedico@gentoo.org> | 2006-03-29 03:17:46 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2006-03-29 03:17:46 +0000 |
commit | ded41d3d8f1033c4f656f69b16daf5e2a53a6b4f (patch) | |
tree | 35071f741066f82e9759942c22f60ac9e25be1e2 | |
parent | 6b796a31cb35cb9c261cd9dd56de4350b3f286e6 (diff) | |
download | portage-ded41d3d8f1033c4f656f69b16daf5e2a53a6b4f.tar.gz portage-ded41d3d8f1033c4f656f69b16daf5e2a53a6b4f.tar.bz2 portage-ded41d3d8f1033c4f656f69b16daf5e2a53a6b4f.zip |
Create a single colorize() function in the output module and use it to generate all of the existing color functions.
svn path=/main/trunk/; revision=3030
-rw-r--r-- | pym/output.py | 65 |
1 files changed, 21 insertions, 44 deletions
diff --git a/pym/output.py b/pym/output.py index f23bac263..e735d4d47 100644 --- a/pym/output.py +++ b/pym/output.py @@ -132,47 +132,24 @@ def nocolor(): def resetColor(): return codes["reset"] -def ctext(color,text): - return codes[ctext]+text+codes["reset"] - -def bold(text): - return codes["bold"]+text+codes["reset"] -def white(text): - return bold(text) - -def teal(text): - return codes["teal"]+text+codes["reset"] -def turquoise(text): - return codes["turquoise"]+text+codes["reset"] -def darkteal(text): - return turquoise(text) - -def fuscia(text): # Don't use this one. It's spelled wrong! - return codes["fuchsia"]+text+codes["reset"] -def fuchsia(text): - return codes["fuchsia"]+text+codes["reset"] -def purple(text): - return codes["purple"]+text+codes["reset"] - -def blue(text): - return codes["blue"]+text+codes["reset"] -def darkblue(text): - return codes["darkblue"]+text+codes["reset"] - -def green(text): - return codes["green"]+text+codes["reset"] -def darkgreen(text): - return codes["darkgreen"]+text+codes["reset"] - -def yellow(text): - return codes["yellow"]+text+codes["reset"] -def brown(text): - return codes["brown"]+text+codes["reset"] -def darkyellow(text): - return brown(text) - -def red(text): - return codes["red"]+text+codes["reset"] -def darkred(text): - return codes["darkred"]+text+codes["reset"] - +def colorize(color_key, text): + return codes[color_key] + text + codes["reset"] + +codes["darkteal"] = codes["turquoise"] +codes["darkyellow"] = codes["brown"] +codes["fuscia"] = codes["fuchsia"] +codes["white"] = codes["bold"] + +compat_functions_colors = ["bold","white","teal","turquoise","darkteal", + "fuscia","fuchsia","purple","blue","darkblue","green","darkgreen","yellow", + "brown","darkyellow","red","darkred"] + +def create_color_func(color_key): + def derived_func(*args): + newargs = list(args) + newargs.insert(0, color_key) + return colorize(*newargs) + return derived_func + +for c in compat_functions_colors: + setattr(sys.modules[__name__], c, create_color_func(c)) |