예제 #1
0
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
예제 #2
0
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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
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)
예제 #6
0
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"
예제 #7
0
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"
예제 #8
0
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)
예제 #9
0
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
예제 #10
0
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}')
예제 #11
0
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'
예제 #12
0
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'
예제 #13
0
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'
예제 #14
0
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
예제 #15
0
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'
예제 #16
0
def _get_full_filepath_by_date(date):
    season = helpers.season_from_date(date)
    directory = f'{base_directory}/{season}/full'
    return f'{directory}/{date}.html'
예제 #17
0
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