Mercurial > libervia-backend
diff sat/tools/common/ansi.py @ 2624:56f94936df1e
code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Jun 2018 20:14:46 +0200 |
parents | 26edcf3a30eb |
children | 003b8b4b56a7 |
line wrap: on
line diff
--- a/sat/tools/common/ansi.py Wed Jun 27 07:51:29 2018 +0200 +++ b/sat/tools/common/ansi.py Wed Jun 27 20:14:46 2018 +0200 @@ -19,15 +19,18 @@ import sys + class ANSI(object): ## ANSI escape sequences ## - RESET = '\033[0m' - NORMAL_WEIGHT = '\033[22m' - FG_BLACK, FG_RED, FG_GREEN, FG_YELLOW, FG_BLUE, FG_MAGENTA, FG_CYAN, FG_WHITE = ('\033[3%dm' % nb for nb in xrange(8)) - BOLD = '\033[1m' - BLINK = '\033[5m' - BLINK_OFF = '\033[25m' + RESET = "\033[0m" + NORMAL_WEIGHT = "\033[22m" + FG_BLACK, FG_RED, FG_GREEN, FG_YELLOW, FG_BLUE, FG_MAGENTA, FG_CYAN, FG_WHITE = ( + "\033[3%dm" % nb for nb in xrange(8) + ) + BOLD = "\033[1m" + BLINK = "\033[5m" + BLINK_OFF = "\033[25m" @classmethod def color(cls, *args): @@ -39,16 +42,19 @@ if args[-1] != cls.RESET: args = list(args) args.append(cls.RESET) - return u''.join(args) + return u"".join(args) try: tty = sys.stdout.isatty() -except (AttributeError, TypeError): # FIXME: TypeError is here for Pyjamas, need to be removed +except ( + AttributeError, + TypeError, +): # FIXME: TypeError is here for Pyjamas, need to be removed tty = False if not tty: - # we don't want ANSI escape codes if we are not outputing to a tty! + # we don't want ANSI escape codes if we are not outputing to a tty! for attr in dir(ANSI): if isinstance(getattr(ANSI, attr), basestring): - setattr(ANSI, attr, u'') + setattr(ANSI, attr, u"") del tty