def _dispatch_handler(args, cell, parser, handler, cell_required=False,
                      cell_prohibited=False):
  """ Makes sure cell magics include cell and line magics don't, before
    dispatching to handler.

  Args:
    args: the parsed arguments from the magic line.
    cell: the contents of the cell, if any.
    parser: the argument parser for <cmd>; used for error message.
    handler: the handler to call if the cell present/absent check passes.
    cell_required: True for cell magics, False for line magics that can't be
      cell magics.
    cell_prohibited: True for line magics, False for cell magics that can't be
      line magics.
  Returns:
    The result of calling the handler.
  Raises:
    Exception if the invocation is not valid.
  """
  if cell_prohibited:
    if cell and len(cell.strip()):
      parser.print_help()
      raise Exception(
          'Additional data is not supported with the %s command.' % parser.prog)
    return handler(args)

  if cell_required and not cell:
    parser.print_help()
    raise Exception('The %s command requires additional data' % parser.prog)

  return handler(args, cell)
Makes sure cell magics include cell and line magics don't, before
    dispatching to handler.

  Args:
    args: the parsed arguments from the magic line.
    cell: the contents of the cell, if any.
    parser: the argument parser for <cmd>; used for error message.
    handler: the handler to call if the cell present/absent check passes.
    cell_required: True for cell magics, False for line magics that can't be
      cell magics.
    cell_prohibited: True for line magics, False for cell magics that can't be
      line magics.
  Returns:
    The result of calling the handler.
  Raises:
    Exception if the invocation is not valid.