示例#1
0
def players_upload():
    f = request.files['players_file']
    if f.filename.endswith('.csv'):
        players = Players.from_csv(f)
    else:
        players = Players.from_xls(f.read())
    db.import_players(players, delete=True)
    flash("Players imported.")
    return redirect(url_for('players'))
示例#2
0
 def test_from_xls(self):
     xls_file = open(os.path.join(os.path.dirname(__file__), "players.xls"))
     players = Players.from_xls(xls_file.read())
     self.assertEqual(
         list(players), [Player("Gary Gygax", "TSR", {"1A": "G"}), Player("Dave Arneson", "TSR", {"1B": "G"})]
     )