/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.43.2 by Parth Malwankar
added unix color codes.
1
# Copyright (C) 2010 Canonical Ltd
2
#
3
# This program 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 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program 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 this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
import os
17
18
class FG(object):
19
    """Unix terminal foreground color codes (16-color)."""
20
    RED = '\033[31m'
21
    GREEN = '\033[32m'
22
    YELLOW = '\033[33m'
23
    BLUE = '\033[34m'
24
    MAGENTA = '\033[35m'
25
    CYAN = '\033[36m'
26
    WHITE = '\033[37m'
27
28
    # Bold Foreground
29
    BOLD_RED = '\033[1;31m'
30
    BOLD_GREEN = '\033[1;32m'
31
    BOLD_YELLOW = '\033[1;33m'
32
    BOLD_BLUE = '\033[1;34m'
33
    BOLD_MAGENTA = '\033[1;35m'
34
    BOLD_CYAN = '\033[1;36m'
35
    BOLD_WHITE = '\033[1;37m'
36
37
class BG(object):
38
    """Unix terminal background color codes (16-color)."""
39
    BLACK = '\033[40m'
40
    RED = '\033[41m'
41
    GREEN = '\033[42m'
42
    YELLOW = '\033[43m'
43
    BLUE = '\033[44m'
44
    MAGENTA = '\033[45m'
45
    CYAN = '\033[46m'
46
    WHITE = '\033[47m'
47
48
    NONE = '\033[0m'
49
50
def color_string_posix(s, fg, bg = ''):
51
    return fg + bg + s + Codes.NONE
52
53
def color_string_nocolor(s, fg, bg = ''):
54
    return bg
55
56
color_string = color_string_posix
57
if os.name != 'posix':
58
    color_string = color_string_nocolor
59