diff options
author | Klement Sekera <klement.sekera@gmail.com> | 2022-04-26 19:02:15 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2022-05-10 18:52:08 +0000 |
commit | d9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch) | |
tree | 4f786cfd8ebc2443cb11e11b74c8657204068898 /test/log.py | |
parent | f90348bcb4afd0af2611cefc43b17ef3042b511c (diff) |
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is
much faster, stable PEP8 compliant code style checker offering also
automatic formatting. It aims to be very stable and produce smallest
diffs. It's used by many small and big projects.
Running checkstyle with black takes a few seconds with a terse output.
Thus, test-checkstyle-diff is no longer necessary.
Expand scope of checkstyle to all python files in the repo, replacing
test-checkstyle with checkstyle-python.
Also, fixstyle-python is now available for automatic style formatting.
Note: python virtualenv has been consolidated in test/Makefile,
test/requirements*.txt which will eventually be moved to a central
location. This is required to simply the automated generation of
docker executor images in the CI.
Type: improvement
Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8
Signed-off-by: Klement Sekera <klement.sekera@gmail.com>
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'test/log.py')
-rw-r--r-- | test/log.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/test/log.py b/test/log.py index 9701aecc04a..f848e221044 100644 --- a/test/log.py +++ b/test/log.py @@ -7,9 +7,9 @@ import logging from config import config """ @var formatting delimiter consisting of '=' characters """ -double_line_delim = '=' * 78 +double_line_delim = "=" * 78 """ @var formatting delimiter consisting of '-' characters """ -single_line_delim = '-' * 78 +single_line_delim = "-" * 78 def colorize(msg, color): @@ -17,13 +17,12 @@ def colorize(msg, color): class ColorFormatter(logging.Formatter): - def init(self, fmt=None, datefmt=None): super(ColorFormatter, self).__init__(fmt, datefmt) def format(self, record): message = super(ColorFormatter, self).format(record) - if hasattr(record, 'color'): + if hasattr(record, "color"): message = colorize(message, record.color) return message @@ -37,8 +36,9 @@ else: log_level = 40 handler = logging.StreamHandler(sys.stdout) -color_formatter = ColorFormatter(fmt='%(asctime)s,%(msecs)03d %(message)s', - datefmt="%H:%M:%S") +color_formatter = ColorFormatter( + fmt="%(asctime)s,%(msecs)03d %(message)s", datefmt="%H:%M:%S" +) handler.setFormatter(color_formatter) handler.setLevel(log_level) @@ -56,7 +56,7 @@ def get_logger(name): def get_parallel_logger(stream): - logger = logging.getLogger('parallel_logger_{!s}'.format(stream)) + logger = logging.getLogger("parallel_logger_{!s}".format(stream)) logger.propagate = False logger.setLevel(logging.DEBUG) handler = logging.StreamHandler(stream) @@ -71,15 +71,15 @@ def get_parallel_logger(stream): # These variables (RED, GREEN, YELLOW and LPURPLE) are used to configure # the color of the text to be printed in the terminal. Variable COLOR_RESET # is used to revert the text color to the default one. -if hasattr(sys.stdout, 'isatty') and sys.stdout.isatty(): - RED = '\033[91m' - GREEN = '\033[92m' - YELLOW = '\033[93m' - LPURPLE = '\033[94m' - COLOR_RESET = '\033[0m' +if hasattr(sys.stdout, "isatty") and sys.stdout.isatty(): + RED = "\033[91m" + GREEN = "\033[92m" + YELLOW = "\033[93m" + LPURPLE = "\033[94m" + COLOR_RESET = "\033[0m" else: - RED = '' - GREEN = '' - YELLOW = '' - LPURPLE = '' - COLOR_RESET = '' + RED = "" + GREEN = "" + YELLOW = "" + LPURPLE = "" + COLOR_RESET = "" |