def load_league_file(league_name): if league_db.league_exists(league_name): state = league_db.state(league_name) this_league = league_structure(league_name) with open( os.path.join(data_dir, league_dir, league_name, f"{this_league.name}.league")) as league_file: this_league.league = jsonpickle.decode(json.load(league_file), keys=True, classes=team) with open( os.path.join(data_dir, league_dir, league_name, f"{this_league.name}.state")) as state_file: state_dic = json.load(state_file) this_league.day = state_dic["day"] this_league.schedule = state_dic["schedule"] this_league.constraints = state_dic["constraints"] this_league.game_length = state_dic["game_length"] this_league.series_length = state_dic["series_length"] this_league.owner = state_dic["owner"] this_league.games_per_hour = state_dic["games_per_hour"] this_league.historic = state_dic["historic"] this_league.season = state_dic["season"] try: this_league.champion = state_dic["champion"] except: this_league.champion = None return this_league
def load_league_file(league_name): if league_db.league_exists(league_name): state = league_db.state(league_name) this_league = league_structure(league_name) with open( os.path.join(data_dir, league_dir, league_name, f"{this_league.name}.league")) as league_file: this_league.league = jsonpickle.decode(json.load(league_file), keys=True, classes=team) with open( os.path.join(data_dir, league_dir, league_name, f"{this_league.name}.state")) as state_file: state_dic = json.load(state_file) this_league.day = state_dic["day"] this_league.schedule = state_dic["schedule"] this_league.constraints = state_dic["constraints"] this_league.game_length = state_dic["game_length"] this_league.series_length = state_dic["series_length"] this_league.owner = state_dic["owner"] this_league.games_per_hour = state_dic["games_per_hour"] this_league.historic = state_dic["historic"] this_league.season = state_dic["season"] try: this_league.champion = state_dic["champion"] except: this_league.champion = None try: this_league.weather_forecast = state_dic[ "forecasts"] #handles legacy leagues except: this_league.weather_forecast = {} for this_team in this_league.teams_in_league( ): #give them all fresh forecasts starting at current day this_league.new_weathers_midseason(this_team.name) save_league(this_league) try: this_league.last_weather_event_day = state_dic[ "last_weather_event"] except: this_league.last_weather_event_day = 0 try: this_league.subbed_channels = state_dic["subs"] except: this_league.subbed_channels = [] return this_league