From e4ccbfe276db5ed098ddcf78a7bb8f2da4263128 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 22 Jan 2012 16:07:32 -0500 Subject: [PATCH] Allow --color=html in hb-diff Not that useful right now as we don't escape < and >. Perhaps another tool can be added to convert the ANSI output to HTML. --- test/shaping/hb-diff | 2 +- test/shaping/hb_test_tools.py | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/test/shaping/hb-diff b/test/shaping/hb-diff index c2ee5300d..29fd11907 100755 --- a/test/shaping/hb-diff +++ b/test/shaping/hb-diff @@ -3,7 +3,7 @@ from hb_test_tools import * import sys, os -colors, sys.argv = Colors.Auto (sys.argv) +colors = Colors.Auto (sys.argv) if len (sys.argv) != 3: print "usage: %s [--color] file1 file2" % sys.argv[0] diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py index b78cdca0a..4b261c1a3 100644 --- a/test/shaping/hb_test_tools.py +++ b/test/shaping/hb_test_tools.py @@ -18,12 +18,24 @@ class Colors: @staticmethod def Auto (argv = [], out = sys.stdout): - if "--color" in argv or os.isatty (out.fileno ()): - if "--color" in sys.argv[1:]: - argv.remove ("--color") - return Colors.ANSI, argv + if os.isatty (out.fileno ()): + color = Colors.ANSI else: - return Colors.Null, argv + color = Colors.Null + if "--color" in argv: + argv.remove ("--color") + color = Colors.ANSI + if "--color=ansi" in argv: + argv.remove ("--color=ansi") + color = Colors.ANSI + if "--color=html" in argv: + argv.remove ("--color=html") + color = Colors.HTML + if "--no-color" in argv: + argv.remove ("--no-color") + color = Colors.Null + return color + @staticmethod def Default (argv = []):