Пример #1
0
                    proj_path + file_name)


def create_dk_upload(lups, pos_order):
    print('Create lu_upload for DK.')
    with open(c.FILEPATHS['lu_upload'], 'wb') as lu_upload:
        lu_upload_writer = csv.writer(lu_upload)
        lu_upload_writer.writerow(pos_order)

        for lu in lups:
            sorted_players = lu.sorted_players()
            lu_upload_writer.writerow([p.player_id for p in sorted_players])


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

    pre_req_check()

    # Do we need a database?
    engine = None
    session = None

    if (args.commit):
        init_db()
        clean_lineups()
    else:
        print(
            'Nothing will be saved to database. Files will not be cleaned up.')

    all_players = retrieve_players_with_salaries()
Пример #2
0
def check_validity(args):
    if args.projection_file:
        with open(args.projection_file, 'rb') as csvfile:
            csvdata = csv.DictReader(csvfile)
            fieldnames = csvdata.fieldnames
            errors = []
            for f in ['playername', 'points']:
                if f not in fieldnames:
                    errors.append(f)

            if len(errors) > 0:
                raise Exception(dke.CSV_ERROR.format(errors))


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

    uploader = None
    if args.league == 'NBA':
        uploader = nba_upload
    elif args.league == 'MLB':
        uploader = mlb_upload
    else:
        uploader = nfl_upload

    if not args.keep_pids:
        uploader.create_upload_file()
    if args.pids:
        player_map = uploader.map_pids(args.pids)