code: def process_pure_python(self, content):
          
          output = []
          savefig = False # keep up with this to clear figure
          multiline = False # to handle line continuation
          multiline_start = None
          fmtin = self.promptin
  
          ct = 0
  
          for lineno, line in enumerate(content):
  
              line_stripped = line.strip()
              if not len(line):
                  output.append(line)
                  continue
  
              # handle decorators
              if line_stripped.startswith('@'):
                  output.extend([line])
                  if 'savefig' in line:
                      savefig = True # and need to clear figure
                  continue
  
              # handle comments
              if line_stripped.startswith('#'):
                  output.extend([line])
                  continue
  
              # deal with lines checking for multiline
              continuation  = u'   %s:'% ''.join(['.']*(len(str(ct))+2))
              if not multiline:
                  modified = u"%s %s" % (fmtin % ct, line_stripped)
                  output.append(modified)
                  ct += 1
                  try:
                      ast.parse(line_stripped)
                      output.append(u'')
                  except Exception: # on a multiline
                      multiline = True
                      multiline_start = lineno
              else: # still on a multiline
                  modified = u'%s %s' % (continuation, line)
                  output.append(modified)
                  try:
                      mod = ast.parse(
                              '\n'.join(content[multiline_start:lineno+1]))
                      if isinstance(mod.body[0], ast.FunctionDef):
                          # check to see if we have the whole function
                          for element in mod.body[0].body:
                              if isinstance(element, ast.Return):
                                  multiline = False
                      else:
                          output.append(u'')
                          multiline = False
                  except Exception:
                      pass
  
              if savefig: # clear figure if plotted
                  self.ensure_pyplot()
                  self.process_input_line('plt.clf()', store_history=False)
                  self.clear_cout()
                  savefig = False
  
          return output
docs: content is a list of strings. it is unedited directive conent
  
          This runs it line by line in the InteractiveShell, prepends
          prompts as needed capturing stderr and stdout, then returns
          the content as a list as if it were ipython code