def extension_from_filename(filename):
    """
    Parse out filename from any specified extensions.
    Returns rootname and string version of extension name.
    """
    _indx1 = filename.find('[')
    _indx2 = filename.find(']')
    if _indx1 > 0:
        if _indx2 < _indx1:
            raise RuntimeError(
                "Incorrect extension specification in file name '%s'." %
                filename)
        _fname = filename[:_indx1]
        _extn = filename[_indx1 + 1:_indx2].strip()
    else:
        _fname = filename
        _extn = None
    return _fname, _extn
