def _clear_old_remotes():
    '''
    Remove cache directories for remotes no longer configured
    '''
    bp_ = os.path.join(__opts__['cachedir'], 'hgfs')
    try:
        cachedir_ls = os.listdir(bp_)
    except OSError:
        cachedir_ls = []
    repos = init()
    # Remove actively-used remotes from list
    for repo in repos:
        try:
            cachedir_ls.remove(repo['hash'])
        except ValueError:
            pass
    to_remove = []
    for item in cachedir_ls:
        if ('hash', 'refs') in item:
            continue
        path = os.path.join(bp_, item)
        if os.path.isdir(path):
            to_remove.append(path)
    failed = []
    if to_remove:
        for rdir in to_remove:
            try:
                shutil.rmtree(rdir)
            except OSError as exc:
                log.error(
                    'Unable to remove old hgfs remote cachedir {0}: {1}'
                    .format(rdir, exc)
                )
                failed.append(rdir)
            else:
                log.debug('hgfs removed old cachedir {0}'.format(rdir))
    for fdir in failed:
        to_remove.remove(fdir)
    return bool(to_remove), repos
dataset/ETHPy150Open saltstack/salt/salt/fileserver/hgfs.py/_clear_old_remotes/swapped operands of `in`