def make_semi_penetrable(sequence):
    def filter(files):

        for f in files:
            if re.match(sequence, f):
                return True

        return False

    return filter


if __name__ == "__main__":
    pr = PrettyPrintTime()
    pr.restart()
    arguments = argparse.Argumentarg().parse_args()
    root = arguments.source
    sequence = ".*\{}$".format(arguments.ext)
    masker_fcn = make_semi_penetrable(sequence)
    dirs = create_walks(root, masker_fcn)

    for path in dirs:
        mp4_f = [f for f in os.listdir(path) if re.match(sequence, f)]
        for v in mp4_f:
            mp4_directory = os.path.join(path, v)
            np_path = mp4_directory + "_pred.npy"
            answer = make_video_func(mp4_directory, arguments.model, arguments.frequency)
            np.save(np_path, answer)
            pr.the_time()

    pr.the_total_time()
                    elif label_list[1] in l_l:
                        vidcutter(vid_name, tmt, siz, arr[3], rad[3])
                        arr[3] += 1
                        if onthetop_eve(l_ls, tstamp[0], tmn,
                                        siz) is False and tmnb:
                            vidcutter(vid_name, tmn, siz, arr[1], rad[1])
                            arr[1] += 1

                    elif label_list[2] in l_l:
                        vidcutter(vid_name, tmt, siz, arr[2], rad[2])
                        arr[2] += 1
                        if onthetop_eve(l_ls, tstamp[0], tmn,
                                        siz) is False and tmnb:
                            vidcutter(vid_name, tmn, siz, arr[1], rad[1])
                            arr[1] += 1


if __name__ == "__main__":
    ga = argparse.Argumentarg()
    ga.add_argument("source_dir",
                    type=str,
                    help="source directory for videos and labels")
    ga.add_argument("ret_ans_dir",
                    type=str,
                    help="ret_ans directory for labeled video clips")
    argts = ga.parse_args()
    if not os.path.exists(argts.ret_ans_dir):
        os.mkdir(argts.ret_ans_dir)

    create_clips(create_walks(argts.source_dir, masker), argts.ret_ans_dir, 10)