code: def create_named_notebook(fname, context):
      
  
      if os.path.exists(fname):
          return
  
      from nbformat import v4 as nbf
  
      # Courtesy of http://nbviewer.ipython.org/gist/fperez/9716279
      text = "Welcome to *pyramid_notebook!* Use *File* *>* *Shutdown* to close this."
      cells = [nbf.new_markdown_cell(text)]
  
      greeting = context.get("greeting")
      if greeting:
          cells.append(nbf.new_markdown_cell(greeting))
  
      cells.append(nbf.new_code_cell(''))
  
      nb = nbf.new_notebook(cells=cells)
  
      with open(fname, 'w') as f:
          writer = JSONWriter()
          writer.write(nb, f)
docs: Create a named notebook if one doesn't exist.