winbind: Keep "force_reauth" in invalidate_cm_connection
[Samba.git] / python / samba / colour.py
blobb3d9a718e0e658d12f49a5d19d4c6facfe2ad11e
1 # ANSI codes for 4 bit and xterm-256color
3 # Copyright (C) Andrew Bartlett 2018
5 # Originally written by Douglas Bagnall
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # The 4 bit colours are available as global variables with names like
21 # RED, DARK_RED, REV_RED (for red background), and REV_DARK_RED.
23 # The 256-colour codes are obtained using xterm_256_color(n), where n
24 # is the number of the desired colour.
26 # C_NORMAL resets to normal, whatever that is
27 C_NORMAL = "\033[0m"
29 UNDERLINE = "\033[4m"
31 def _gen_ansi_colours():
32 g = globals()
33 for i, name in enumerate(('BLACK', 'RED', 'GREEN', 'YELLOW', 'BLUE',
34 'MAGENTA', 'CYAN', 'WHITE')):
35 g[name] = "\033[1;3%dm" % i
36 g['DARK_' + name] = "\033[3%dm" % i
37 g['REV_' + name] = "\033[1;4%dm" % i
38 g['REV_DARK_' + name] = "\033[4%dm" % i
40 _gen_ansi_colours()
42 # kcc.debug uses these aliases (which make visual sense)
43 PURPLE = DARK_MAGENTA
44 GREY = DARK_WHITE
46 def xterm_256_colour(n, bg=False, bold=False):
47 weight = '01;' if bold else ''
48 target = '48' if bg else '38'
50 return "\033[%s%s;5;%dm" % (weight, target, int(n))