code: def fmt_text(text, bg = None, fg = None, attr = None, plain = False):
          
          if not plain:
              if fg is not None:
                  text = TEXT_FORMATING['fg'][fg] + text
              if bg is not None:
                  text = TEXT_FORMATING['bg'][bg] + text
              if attr is not None:
                  text = TEXT_FORMATING['attr'][attr] + text
              if (fg is not None) or (bg is not None) or (attr is not None):
                  text += TEXT_FORMATING['rst']
          return text
docs: Apply given console formating around given text.