js/src/tests/lib/terminal_unix.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 import sys
     3 class Terminal(object):
     4     COLOR = {
     5         'red': '31',
     6         'green': '32',
     7         'blue': '34',
     8         'gray': '37'
     9     }
    10     NORMAL_INTENSITY = '1'
    11     BRIGHT_INTENSITY = '2'
    12     ESCAPE = '\x1b['
    13     RESET = '0'
    14     SEPARATOR = ';'
    15     COLOR_CODE = 'm'
    16     CLEAR_RIGHT_CODE = 'K'
    18     @classmethod
    19     def set_color(cls, color):
    20         """
    21         color: str - color definition string
    22         """
    23         mod = Terminal.NORMAL_INTENSITY
    24         if color.startswith('bright'):
    25             mod = Terminal.BRIGHT_INTENSITY
    26             color = color[len('bright'):]
    27         color_code = Terminal.COLOR[color]
    29         sys.stdout.write(cls.ESCAPE + color_code + cls.SEPARATOR + mod + cls.COLOR_CODE)
    31     @classmethod
    32     def reset_color(cls):
    33         sys.stdout.write(cls.ESCAPE + cls.RESET + cls.COLOR_CODE)
    35     @classmethod
    36     def clear_right(cls):
    37         sys.stdout.write(cls.ESCAPE + cls.CLEAR_RIGHT_CODE)

mercurial