def ErrorContextPrinter(header, empty, modifier=None, singleton=None):
  """Creates a function that prints extra error data.

  Args:
    header: What to print before the data.
    empty: What to print when there's no data.
    modifier: Optional, run on all the data before printing.
    singleton: Optional, what to print when there's only one datum.
  Returns:
    Function that takes (data, printer) and prints the data using the printer.
  """

  def WriteExtraData(data, printer):
    data = list(modifier(data) if modifier else data)
    if data:
      if not singleton or len(data) > 1:
        printer(header, end=':\n')
        for datum in data:
          if datum is None:
            printer('')
          else:
            printer(str(datum))
      else:
        printer(singleton % data[0])
    else:
      printer(empty)

  return WriteExtraData


# Pylint isn't smart enough to notice that these are all generated functions.
dataset/ETHPy150Open google/vroom/vroom/output.py/ErrorContextPrinter/original