Diffusion Cumin efb86bc64c39

dependency: replace colorama with custom module


dependency: replace colorama with custom module

  • In stretch there is a regression in colorama in conjunction with tqdm that leads to a slow down of the progress of the script proportional to the amount of data printed to stdout/err. Colorama starts having very huge stacktraces and the process is stuck at 100% CPU for an increasingly amount of time while more data is printed.
  • Given the very simple usage of colors that is made in Cumin as of now, it seems much more feasible to replace the colorama library (as all that cross-OS support is not needed) and add a simple module with ANSI escape sequence support.
  • Use a type (metaclass) to be able to override getattr for the staticmethods of the classes that use it and to automatically define a method for each color in a DRY way without code duplication.
  • Define a Colored class that uses ColoredType as metaclass to inherit its type with the custom behaviour.
  • For each color defined in ColoredType.COLORS a method of Colored is defined, e.g. Colored.red().
  • The Colored class has a disabled property that can be set to True to globally disable coloring. This could for example be integrated later into the CLI as an option to disable colors or allow to add some code to the color.py module to autodetect when not in a TTY and automatically disable all colors.

Bug: T217038
Change-Id: I053972e92b7cc6cf7821de8ecff484d01be03794


VolansAuthored on Jan 10 2019, 12:26 AM
rCUMIN79d83010acf7: setup.py: limit max version of tqdm