root/cleverbox/trunk/cleverbox/utils/styles.py

Revision 260, 1.7 KB (checked in by trivoallan, 4 years ago)

cleverbox :

  • Added licence information to all project's file. Fixes #28
  • Fixed version number in O.4's setup.py
Line 
1# This file is part of the "Cleverbox" program.
2#
3# Cleverbox is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 3 of the License, or
6# (at your option) any later version.
7#
8# Cleverbox is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with Cleverbox.  If not, see <http://www.gnu.org/licenses/>.
15#
16# Copyright 2008, Tristan Rivoallan
17
18import sys
19from cleverbox.utils import termcolors
20
21# Set up the terminal color scheme.
22class dummy: pass
23style = dummy()
24style.ERROR = termcolors.make_style(fg='red', opts=('bold',))
25style.WARNING = termcolors.make_style(fg='yellow', opts=('bold',))
26style.SUCCESS = termcolors.make_style(fg='green', opts=('bold',))
27style.H1 = termcolors.make_style(fg='white', opts=('bold', 'underline'))
28style.ENABLED = termcolors.make_style(fg='green', opts=('bold',))
29style.DISABLED = termcolors.make_style(fg='red')
30
31style.SUCCESSNORESET = termcolors.make_style(fg='green', opts=('bold', 'noreset',))
32style.RESET = termcolors.make_style()
33del dummy
34
35def disable_termcolors():
36    class dummy:
37        def __getattr__(self, attr):
38            return lambda x: x
39    global style
40    style = dummy()
41
42# Disable terminal coloring on Windows, Pocket PC, or if somebody's piping the output.
43if sys.platform == 'win32' or sys.platform == 'Pocket PC' or not sys.stdout.isatty():
44    disable_termcolors()
Note: See TracBrowser for help on using the browser.