def parse_filename(fname):
if fname.endswith(u'<STR_LIT>'):<EOL><INDENT>format = u'<STR_LIT>'<EOL><DEDENT>elif fname.endswith(u'<STR_LIT>'):<EOL><INDENT>format = u'<STR_LIT>'<EOL><DEDENT>elif fname.endswith(u'<STR_LIT>'):<EOL><INDENT>format = u'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>fname = fname + u'<STR_LIT>'<EOL>format = u'<STR_LIT>'<EOL><DEDENT>name = fname.split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>return fname, name, format<EOL>
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
        extention (.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.