def league_teams(): """ Get list of all league teams """ return League.load().teams
def league_current(self): return League.load()
def generate_file(filename, inactive, archive, include_items, unscattered): sim = SimulationData.load() if archive and os.path.isfile(filename): os.rename( filename, filename.replace(".csv", "S{}preD{}.csv".format(sim.season, sim.day + 1)), ) output = [] positions = (("lineup", "rotation", "shadows") if inactive else ("lineup", "rotation")) league = League.load() players = Player.load_all() for subleague in league.subleagues.values(): for division in subleague.divisions.values(): for team in division.teams.values(): for position in positions: for turn_order, player_id in enumerate( getattr(team, "_{}_ids".format(position))): player = players[player_id] if include_items: player = adjust_stlats_for_items(player) player_row = [ team.full_name, subleague.name, division.name, player.name if not unscattered or "unscatteredName" not in player.state else player.state["unscatteredName"], position, turn_order + 1, player.id, player.anticapitalism, player.base_thirst, player.buoyancy, player.chasiness, player.coldness, player.continuation, player.divinity, player.ground_friction, player.indulgence, player.laserlikeness, player.martyrdom, player.moxie, player.musclitude, player.bat.id or "", player.omniscience, player.overpowerment, player.patheticism, player.ruthlessness, player.shakespearianism, player.suppression, player.tenaciousness, player.thwackability, player.tragicness, player.unthwackability, player.watchfulness, player.pressurization, player.total_fingers, player.soul, player.deceased, player.peanut_allergy, player.cinnamon, player.fate, player.armor.id or "", player.ritual, player._blood_id, player._coffee_id, ";".join(attr.id for attr in player.perm_attr + player.item_attr), ";".join(attr.id for attr in player.seas_attr), ";".join(attr.id for attr in player.week_attr), ";".join(attr.id for attr in player.game_attr), player.batting_rating * 5.0, player.pitching_rating * 5.0, player.baserunning_rating * 5.0, player.defense_rating * 5.0, ] output.append(player_row) output.sort(key=operator.itemgetter(0, 4, 5)) with open(filename, "w") as f: f.write("{}\n".format(",".join('"{}"'.format(col) for col in COLUMNS))) f.write("\n".join(",".join(['"{}"'.format(d) for d in datarow]) for datarow in output))