def f_remove(fpath):
    """
    If exist, remove. Supports both dir and file. Supports glob wildcard.
    """
    fpath = f_expand(fpath)
    for f in glob.glob(fpath):
        try:
            shutil.rmtree(f)
        except OSError as e:
            if e.errno == errno.ENOTDIR:
                try:
                    os.remove(f)
                except: # final resort safeguard
                    pass

    If exist, remove. Supports both dir and file. Supports glob wildcard.
    
surreal/utils/filesys.py