def swish_analytics_files_on_date(date): season = helpers.season_from_date(date) for site in valid_sites: directory = f'{base_directory}/{season}/{site}' filename = f'{date}.json' filepath = f'{directory}/{filename}' yield filepath
def load_odds_by_date(date): logger.info(f'Loading odds on {date}.') season = helpers.season_from_date(date) filepath = f'{base_directory}/{season}/{date}.html' if not os.path.exists(filepath): logger.warning(f'No VI file at {filepath}. Returning.') return load_odds_from_file(date, filepath)
def load_players_on_date(self, date, force=False): season = helpers.season_from_date(date) directory = f'{self.base_directory}/{season}/{self.site_abbrv}' filepath = f'{directory}/{date}.csv' utils.load_players_from_file(filepath, self.site_abbrv, self._name_from_row, force=force)
def load_salaries_positions_for_date(self, date): print(f'Loading {self.site_abbrv} salaries and positions for {date}') season = helpers.season_from_date(date) directory = f'{self.base_directory}/{season}/{self.site_abbrv}' for fn in os.listdir(directory): if fn.startswith(date): filepath = f'{directory}/{fn}' self.load_salaries_positions_for_date_with_filepath( date, filepath)
def load_projections_for_date(date): logger.info(f'Loading DFN projections on {date}.') season = helpers.season_from_date(date) for site_abbrv in valid_sites: filepath = f'{base_directory}/{season}/{site_abbrv}/{date}.csv' if not os.path.exists(filepath): logger.warning(f'No DFN file at {filepath}. Returning.') return load_projections_from_file(site_abbrv, date, filepath)
def _get_csv_filepath_from_date(date, site_abbrv): ''' To make it easier to know where the data is going. data_type refers to whether it's the csv data or json since rg has both. ''' season = helpers.season_from_date(date) directory = f'{base_directory}/csvs/{season}/{site_abbrv}' utils.ensure_directory_exists(directory) return f"{directory}/{date}.csv"
def get_json_filepath_from_date(date, base_directory): ''' To make it easier to know where the data is going. data_type refers to whether it's the csv data or json since rg has both. ''' season = helpers.season_from_date(date) directory = f'{base_directory}/json/{season}' ensure_directory_exists(directory) return f"{directory}/{date}.json"
def gather_salary_changes_by_date(date): print(f'Getting salary differences from SA for {date}') page = requests.get(base_url, params={'date': date}) season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/full' utils.ensure_directory_exists(directory) filename = f'{date}.html' filepath = f'{directory}/{filename}' with open(filepath, 'w') as f: f.write(page.text)
def gather_odds_by_date(date): logger.info(f'Gathering odds for {date}') url = odds_url % date page = requests.get(url) season = helpers.season_from_date(date) directory = f'{base_directory}/{season}' utils.ensure_directory_exists(directory) filename = f'{date}.html' filepath = f'{directory}/{filename}' with open(filepath, 'w') as f: f.write(page.text) return date
def load_salaries_on_date(date): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/full' for site in valid_sites: filename = f'{date}.json' filepath = f'{directory}/{filename}' with open(filepath, 'r') as f: player_salaries = json.load(f) print(player_salaries) for player in player_salaries: player_name = player['player_name'] salary = int(player['salary'].replace(',', '')) print(f'{player_name}: {salary}')
def _contest_draftgroup_filepath_for_date(date, dgid): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/contests/{date}' utils.ensure_directory_exists(directory) return f'{directory}/{dgid}.json'
def _contest_info_filepath_for_date(date): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/contests/{date}' utils.ensure_directory_exists(directory) return f'{directory}/contest_info.json'
def _get_site_filepath_by_date(site_abbrv, date): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/{site_abbrv}' utils.ensure_directory_exists(directory) return f'{directory}/{date}.json'
def _get_json_file_for_date_and_site(date, site_abbrv): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/json/{site_abbrv}' utils.ensure_directory_exists(directory) filepath = f'{directory}/{date}.json' return filepath
def _slate_player_info_filepath_for_date(slate_id, date): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/players/{date}' utils.ensure_directory_exists(directory) return f'{directory}/{slate_id}.json'
def _get_full_filepath_by_date(date): season = helpers.season_from_date(date) directory = f'{base_directory}/{season}/full' return f'{directory}/{date}.html'
def box_scores_directory_from_date(date): _, month, _ = date.split('-') season = helpers.season_from_date(date) directory = f"{box_scores_base_directory}/{season}/{month}/{date}" utils.ensure_directory_exists(directory) return directory