示例#1
0
def players_advanced_season_totals(season_end_year,
                                   include_combined_values=False,
                                   output_type=None,
                                   output_file_path=None,
                                   output_write_option=None,
                                   json_options=None):
    try:
        http_service = HTTPService(parser=ParserService())
        values = http_service.players_advanced_season_totals(
            season_end_year, include_combined_values=include_combined_values)
    except requests.exceptions.HTTPError as http_error:
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    options = OutputOptions.of(file_options=FileOptions.of(
        path=output_file_path, mode=output_write_option),
                               output_type=output_type,
                               json_options=json_options,
                               csv_options={
                                   "column_names":
                                   PLAYER_ADVANCED_SEASON_TOTALS_COLUMN_NAMES
                               })
    output_service = OutputService(
        json_writer=JSONWriter(value_formatter=BasketballReferenceJSONEncoder),
        csv_writer=CSVWriter(value_formatter=format_value))
    return output_service.output(data=values, options=options)
示例#2
0
def players_advanced_season_totals(season_end_year,
                                   include_combined_values=False,
                                   output_type=None,
                                   output_file_path=None,
                                   output_write_option=None,
                                   json_options=None):
    try:
        values = http_client.players_advanced_season_totals(
            season_end_year, include_combined_values=include_combined_values)
    except requests.exceptions.HTTPError as http_error:
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    return output(
        values=values,
        output_type=output_type,
        output_file_path=output_file_path,
        output_write_option=output_write_option,
        csv_writer=CSVWriter(
            column_names=PLAYER_ADVANCED_SEASON_TOTALS_COLUMN_NAMES,
            row_formatter=RowFormatter(
                data_field_names=PLAYER_ADVANCED_SEASON_TOTALS_COLUMN_NAMES)),
        json_options=json_options,
    )
示例#3
0
def players_season_totals(season_end_year,
                          output_type=None,
                          output_file_path=None,
                          output_write_option=None,
                          json_options=None):
    try:
        http_service = HTTPService(parser=ParserService())
        values = http_service.players_season_totals(
            season_end_year=season_end_year)
    except requests.exceptions.HTTPError as http_error:
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    return output(
        values=values,
        output_type=output_type,
        output_file_path=output_file_path,
        output_write_option=output_write_option,
        csv_writer=CSVWriter(
            column_names=PLAYER_SEASON_TOTALS_COLUMN_NAMES,
            row_formatter=RowFormatter(
                data_field_names=PLAYER_SEASON_TOTALS_COLUMN_NAMES)),
        json_options=json_options,
    )
def players_season_totals(season_end_year, output_type=None, output_file_path=None, output_write_option=None, json_options=None):
    try:
        values = http_client.players_season_totals(season_end_year)
    except requests.exceptions.HTTPError as http_error:
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    return output(
        values=values,
        output_type=output_type,
        output_file_path=output_file_path,
        output_write_option=output_write_option,
        csv_writer=players_season_totals_to_csv,
        encoder=BasketballReferenceJSONEncoder,
        json_options=json_options,
    )
def season_schedule(season_end_year, output_type=None, output_file_path=None, output_write_option=None, json_options=None):
    try:
        values = http_client.season_schedule(season_end_year)
    except requests.exceptions.HTTPError as http_error:
        # https://github.com/requests/requests/blob/master/requests/status_codes.py#L58
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    return output(
        values=values,
        output_type=output_type,
        output_file_path=output_file_path,
        output_write_option=output_write_option,
        csv_writer=schedule_to_csv,
        encoder=BasketballReferenceJSONEncoder,
        json_options=json_options,
    )
示例#6
0
def standings(season_end_year,
              output_type=None,
              output_file_path=None,
              output_write_option=None,
              json_options=None):
    try:
        http_service = HTTPService(parser=ParserService())
        values = http_service.standings(season_end_year=season_end_year)
    except requests.exceptions.HTTPError as http_error:
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    options = OutputOptions.of(
        file_options=FileOptions.of(path=output_file_path,
                                    mode=output_write_option),
        output_type=output_type,
        json_options=json_options,
        csv_options={"column_names": STANDINGS_COLUMNS_NAMES})
    output_service = OutputService(
        json_writer=JSONWriter(value_formatter=BasketballReferenceJSONEncoder),
        csv_writer=CSVWriter(value_formatter=format_value))
    return output_service.output(data=values, options=options)
示例#7
0
def season_schedule(season_end_year,
                    output_type=None,
                    output_file_path=None,
                    output_write_option=None,
                    json_options=None):
    try:
        values = http_client.season_schedule(season_end_year)
    except requests.exceptions.HTTPError as http_error:
        # https://github.com/requests/requests/blob/master/requests/status_codes.py#L58
        if http_error.response.status_code == requests.codes.not_found:
            raise InvalidSeason(season_end_year=season_end_year)
        else:
            raise http_error
    return output(
        values=values,
        output_type=output_type,
        output_file_path=output_file_path,
        output_write_option=output_write_option,
        csv_writer=CSVWriter(column_names=SCHEDULE_COLUMN_NAMES,
                             row_formatter=RowFormatter(
                                 data_field_names=SCHEDULE_COLUMN_NAMES)),
        json_options=json_options,
    )