mil icon indicating copy to clipboard operation
mil copied to clipboard

Convert colors in `mil_misc_tools.FprintFactory` to an `enum.Enum`

Open cbrxyz opened this issue 2 years ago • 0 comments

The mil_misc_tools.FprintFactory factory class currently uses a custom class to hold the unicode characters to color text as individual class variables. To obtain these unicode characters from outside the module, other modules will frequently refer to the color as a string.

Instead, this could be converted to an enumerator to provide greater code clarity and reliability, while also adding some code completion features. This would help prevent an unassuming MIL member from accidentally trying to print a message in a color that doesn't exist to FprintFactory!

For example, this is how the code is structured now:

from mil_misc_tools import text_effects
fprint = text_effects.FprintFactory(title="PINGER", msg_color="cyan").fprint

This could be restructured as:

from mil_misc_tools import text_effects, PrintColors
fprint = text_effects.FprintFactory(title="PINGER", msg_color=PrintColors.cyan).fprint

cbrxyz avatar Mar 06 '22 05:03 cbrxyz