def f_add_ext(fpath, ext):
    """
    Append an extension if not already there
    Args:
      ext: will add a preceding `.` if doesn't exist
    """
    if not ext.startswith('.'):
        ext = '.' + ext
    if fpath.endswith(ext):
        return fpath
    else:
        return fpath + ext

    Append an extension if not already there
    Args:
      ext: will add a preceding `.` if doesn't exist
    
surreal/utils/filesys.py