示例#1
0
    g = parser.parse_args()
    output = dict()  # type: Dict[str, Image]

    if g.flag:
        output.update([make_pic(['0', g.flag])])
    elif g.flags:
        for flag, i in zip(count(), g.flags):
            output[i] = make_pic([i, flag])[1]

    elif g.where and g.from_file:
        from flags_and_teams import data
        pool = Pool(5, initializer=initializer, initargs=(g.where))
        if not os.path.exists(g.where):
            os.makedirs(g.where)
        pool.map(make_and_save, tqdm(list(data.items())))
        exit(0)

    elif g.from_file:
        from flags_and_teams import data
        for team_id, flag in data.items():
            output.update([make_pic([team_id, flag])])

    print(output)
    if g.v:
        for team, pic in output.items():
            pic.show()
    elif g.where:
        if not os.path.exists(g.where):
            os.makedirs(g.where)
        for team_id, flag in output.items():
示例#2
0
    parser = argparse.ArgumentParser(description="Make dem tasks")
    parser.add_argument('where',
                        help="Where would you like task files outputted to")
    flag_group = parser.add_mutually_exclusive_group()
    flag_group.add_argument('--flags',
                            help="File to take flags from",
                            type=list)
    flag_group.add_argument('--flag', help="Single flag to be hidden")
    parser.add_argument('--v', help="Print made tasks", action="store_true")
    g = parser.parse_args()
    output = dict()  # type: Dict[str, Tuple[str, str]]
    if g.flag:
        output[0] = make_task(g.flag)
    elif g.flags:
        for i, flag in zip(count(), g.flags):
            output[i] = make_task(flag)
    else:
        from flags_and_teams import data
        for team_id, flag in data.items():
            output[team_id] = make_task(flag)

    if g.v:
        print(output)
    else:
        for team_id, flag in output.items():
            with open(g.where, 'w+') as f:
                f.write("tasks = ")
                f.write(repr(list(output.values())))
                f.write("\nanswers = ")
                f.write(repr(list(output.keys())))
示例#3
0

def insert_flag(container, flag, ratio):
    result = []
    for c, f in zip(container, cycle(flag)):
        result.extend([c, c + int(f * ratio)])
    return result


if __name__ == '__main__':
    args = get_args()

    if not os.path.exists(args.dir):
        os.makedirs(args.dir)

    if args.folders:
        path = '%s/%%s/sound.wav' % args.dir
    else:
        path = '%s/%%s.wav' % args.dir

    i = 0
    container = load_wav_amps(args.container)
    from flags_and_teams import data
    for token, flag in data.items():
        print('%d: Processing token %s' % (i, token))
        result = insert_flag(container, build_flag(flag), args.ratio)
        if args.folders:
            os.makedirs('%s/%s' % (args.dir, token))
        save_stereo_wav(path % token, result)
        i += 1