code: def parse_filename(fname):
      """Parse a notebook filename.
  
      This function takes a notebook filename and returns the notebook
      format (json/py) and the notebook name. This logic can be
      summarized as follows:
  
      * notebook.ipynb -> (notebook.ipynb, notebook, json)
      * notebook.json  -> (notebook.json, notebook, json)
      * notebook.py    -> (notebook.py, notebook, py)
      * notebook       -> (notebook.ipynb, notebook, json)
  
      Parameters
      ----------
      fname : unicode
          The notebook filename. The filename can use a specific filename
          extension (.ipynb, .json, .py) or none, in which case .ipynb will
          be assumed.
  
      Returns
      -------
      (fname, name, format) : (unicode, unicode, unicode)
          The filename, notebook name and format.
      """
      basename, ext = os.path.splitext(fname)  # noqa: PTH122
      if ext in [".ipynb", ".json"]:
          format_ = "json"
      elif ext == ".py":
          format_ = "py"
      else:
          basename = fname
          fname = fname + ".ipynb"
          format_ = "json"
      return fname, basename, format_
  
file_path: nbformat/nbformat/v2/__init__.py
imports: from __future__ import annotations
  import os
  from .convert import downgrade, upgrade
  from .nbbase import NotebookNode, new_author, new_code_cell, new_metadata, new_notebook, new_output, new_text_cell, new_worksheet
  from .nbjson import reads
  from .nbjson import reads
  from .nbjson import to_notebook
  from .nbjson import writes
  from .nbjson import writes
  from .nbpy import reads
  from .nbpy import reads
  from .nbpy import to_notebook
  from .nbpy import writes
  from .nbpy import writes
  from .nbxml import reads
  from .nbxml import reads
  from .nbxml import to_notebook
label_desc: Use image node_id 1 for calling a global function with example usage: parse_filename(fname) and returns: fname,  basename,  format_