#!/usr/bin/env python3 -u# Copyright (c) Facebook, Inc. and its affiliates.## This source code is licensed under the MIT license found in the# LICENSE file in the root directory of this source tree.importosimportargparseimportsysparser=argparse.ArgumentParser()parser.add_argument("--tsv",required=True,type=str)parser.add_argument("--no-skip",action="store_true")parser.add_argument("--keep",action="store_true")params=parser.parse_args()defget_fname(line):p=os.path.basename(line.split("\t")[0])p=os.path.splitext(p)[0]returnp# filenames to excludeseen=set()withopen(params.tsv)asf:ifnotparams.no_skip:root=next(f).rstrip()forlineinf:seen.add(get_fname(line))fori,lineinenumerate(sys.stdin):exists=get_fname(line)inseenkeep=(existsandparams.keep)or(notexistsandnotparams.keep)ifi==0orkeep:print(line,end="")