docs: def _fmt_context(arg_list, context):
      """
      Iterate on performing a format operation until the formatting makes no
      further changes.  This allows for the substitution of context values that
      themselves have context values.  To prevent infinite loops due to direct
      or indirect self-reference, the total number of attempts is limited.
  
      On any error, the string formatted so far is returned.
  
      For convenience, if passed a list, each element will be formatted and
      the resulting list will be returned
  """
      if arg_list is None:
          return arg_list
      just_one = False
      if not isinstance(arg_list, list):
          arg_list = [arg_list]
          just_one = True
      ans = []
      for arg in arg_list:
          if arg is None:                                                                         # pragma: no cover
              continue
          for attempt in range(0, 10):
              res = None
              try:
                  m = _fmt_context_isvar.match(arg)
                  if m and m.group(1) in context and context[m.group(1)] is None:
                      #  Handle case where the var is in the context will
                      #  value None.  If this is left to formatting, it
                      #  gets converted to the string value "None".
                      #
                      break
                  else:
                      res = arg.format(**context)
                      if res == arg:
                          break
                  arg = res
              except:
                  if res is None:
                      #  If the formatting fails, revert to
                      #  last successful value and stop.
                      #
                      res = arg
                  break
          ans.append(res)
      return (ans[0] if just_one else ans)