docstr: Paste & execute a pre-formatted code block from clipboard.
  
  The text is pulled directly from the clipboard without user
  intervention and printed back on the screen before execution (unless
  the -q flag is given to force quiet mode).
  
  The block is dedented prior to execution to enable execution of method
  definitions. '>' and '+' characters at the beginning of a line are
  ignored, to allow pasting directly from e-mails, diff files and
  doctests (the '...' continuation prompt is also stripped).  The
  executed block is also assigned to variable named 'pasted_block' for
  later editing with '%edit pasted_block'.
  
  You can also pass a variable name as an argument, e.g. '%paste foo'.
  This assigns the pasted block to variable 'foo' as string, without
  executing it (preceding >>> and + is still stripped).
  
  Options:
  
    -r: re-executes the block previously entered by cpaste.
  
    -q: quiet mode: do not echo the pasted text back to the terminal.
  
  IPython statements (magics, shell escapes) are not supported (yet).
  
  See also
  --------
  cpaste: manually paste code into terminal until you mark its end.
docstr_tok: ["Paste","&","execute","a","pre-formatted","code","block","from","clipboard",".","The","text","is","pulled","directly","from","the","clipboard","without","user","intervention","and","printed","back","on","the","screen","before","execution","(","unless","the","-q","flag","is","given","to","force","quiet","mode",")",".","The","block","is","dedented","prior","to","execution","to","enable","execution","of","method","definitions",".","'",">","'","and","'+","'","characters","at","the","beginning","of","a","line","are","ignored",",","to","allow","pasting","directly","from","e-mails",",","diff","files","and","doctests","(","the","'","...","'","continuation","prompt","is","also","stripped",")",".","The","executed","block","is","also","assigned","to","variable","named","'pasted_block","'","for","later","editing","with","'","%","edit","pasted_block","'",".","You","can","also","pass","a","variable","name","as","an","argument",",","e.g",".","'","%","paste","foo","'",".","This","assigns","the","pasted","block","to","variable","'foo","'","as","string",",","without","executing","it","(","preceding",">",">",">","and","+","is","still","stripped",")",".","Options",":","-r",":","re-executes","the","block","previously","entered","by","cpaste",".","-q",":","quiet","mode",":","do","not","echo","the","pasted","text","back","to","the","terminal",".","IPython","statements","(","magics",",","shell","escapes",")","are","not","supported","(","yet",")",".","See","also","--","--","--","--","cpaste",":","manually","paste","code","into","terminal","until","you","mark","its","end","."]
code: def paste(self, parameter_s=""):
      """Paste & execute a pre-formatted code block from clipboard.
  
      The text is pulled directly from the clipboard without user
      intervention and printed back on the screen before execution (unless
      the -q flag is given to force quiet mode).
  
      The block is dedented prior to execution to enable execution of method
      definitions. '>' and '+' characters at the beginning of a line are
      ignored, to allow pasting directly from e-mails, diff files and
      doctests (the '...' continuation prompt is also stripped).  The
      executed block is also assigned to variable named 'pasted_block' for
      later editing with '%edit pasted_block'.
  
      You can also pass a variable name as an argument, e.g. '%paste foo'.
      This assigns the pasted block to variable 'foo' as string, without
      executing it (preceding >>> and + is still stripped).
  
      Options:
  
        -r: re-executes the block previously entered by cpaste.
  
        -q: quiet mode: do not echo the pasted text back to the terminal.
  
      IPython statements (magics, shell escapes) are not supported (yet).
  
      See also
      --------
      cpaste: manually paste code into terminal until you mark its end.
      """
      opts, name = self.parse_options(parameter_s, "rq", mode="string")
      if "r" in opts:
          self.rerun_pasted()
          return
      try:
          block = self.shell.hooks.clipboard_get()
      except TryNext as clipboard_exc:
          message = getattr(clipboard_exc, "args")
          if message:
              error(message[0])
          else:
              error("Could not get text from the clipboard.")
          return
      except ClipboardEmpty:
          raise UsageError("The clipboard appears to be empty")
  
      # By default, echo back to terminal unless quiet mode is requested
      if "q" not in opts:
          write = self.shell.write
          write(self.shell.pycolorize(block))
          if not block.endswith("\n"):
              write("\n")
          write("## -- End pasted text --\n")
  
      self.store_or_execute(block, name)
  
file_path: catboost/contrib/python/ipython/py2/IPython/terminal/magics.py
imports: from __future__ import print_function
  from logging import error
  import os
  import sys
  from IPython.core.error import TryNext, UsageError
  from IPython.core.inputsplitter import IPythonInputSplitter
  from IPython.core.magic import Magics, magics_class, line_magic
  from IPython.lib.clipboard import ClipboardEmpty
  from IPython.utils.text import SList, strip_email_quotes
  from IPython.utils import py3compat
label_desc: Use image node_id 7 for calling the TerminalMagics obj's underlying member method code with example usage: obj.paste(parameter_s) without return types