summaryrefslogtreecommitdiff
path: root/python/samba/colour.py
AgeCommit message (Collapse)AuthorFilesLines
2023-10-13python:colour: Fix exception messageJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-24python/colour: add a colour diff helperDouglas Bagnall1-0/+32
Sometimes colour can help show what is different between two strings. This is roughly the same as `git diff --no-index --color-words=. <a> <b>`. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-16py:colour: is_colour_wanted() can take filenamesDouglas Bagnall1-0/+12
We need this for `samba-tool visualize -o -` which means output to stdout, and which has always had a tty test for colour. Rather than continue to duplicate the full logic there, we can reuse this. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-16samba-tool: --color=auto looks at stderr and stdoutDouglas Bagnall1-6/+7
More often than not we are using colour in stderr, but are deciding based on stdout's tty-ness. This patch changes to use both, and will affect the following situation: samba-tool 2>/tmp/errors # used to be colour, now not. of course, if you want colour, you can always samba-tool --color=yes 2>/tmp/errors Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-16py:colour: colour_if_wanted() returns the resultDouglas Bagnall1-1/+3
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-06python/colour: helper functions to read all signsDouglas Bagnall1-0/+38
The accepted hints are presumably arguments to --color. We follow the behaviour of `ls` in what we accept. `git` is stricter, accepting only {always,never,auto}. `grep` is looser accepting mixed case variants. historically we have used {yes,no,auto}. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2018-05-31python/colour: add colourizing and switch functionsDouglas Bagnall1-8/+48
When samba.colour is first imported, the function colour.c_BLUE("samba") will give you the string "\033[1;34msamba\033[0m", which will show up as blue on an ANSI terminal. If you then go: colour.switch_colour_off() colour.c_BLUE("samba") the c_BLUE call will return the uncoloured string "samba". This is so things like samba-tool can do this sort of thing: if not os.isatty(self.outf): switch_colour_off() Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13samba_kcc: kcc.debug module defers to samba.colourDouglas Bagnall1-0/+3
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13python: module containing ANSI colour sequencesDouglas Bagnall1-0/+47
This is going to be used by `samba-tool visualize` and samba_kcc. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>