def process_date_range(self, start_date, end_date): """Ingests GameDay data within a range of specified dates All dates within the begin date and end date are processed. Parameters ---------- start_date: datetime.date object The first date to process. Can also be a string, in which case the function will parse it into a datetime object. end_date: datetime.date object The final date to process. Can also be a string, in which case the function will parse it into a datetime object. """ start_date = util.validate_date(start_date) # Ensure dates are datetime objects end_date = util.validate_date(end_date) if end_date < start_date: tmp = end_date end_date = start_date start_date = tmp date_range = (end_date - start_date).days + 1 # Add 1 so the range is inclusive of begin_date and end_date msg = "Ingesting GameDay data within date range {} to {}".format(start_date.date(), end_date.date()) logger.info(msg) for day in range(date_range): date = start_date + timedelta(day) self.process_date(date)
def process_date(self, date): """Ingests one day of GameDay data Parameters ---------- date : datetime.date object The date to process Can also be a string, in which case the function will parse it into a datetime object. """ date = util.validate_date(date) # Ensure date is a datetime object epg_page = scrape.fetch_epg(date.year, date.month, date.day) if epg_page is None: msg = "No games found on {}".format(date.date()) logger.warn(msg) else: game_xml_nodes = parse.parse_epg(epg_page) msg = "Processing {} games on {}".format(len(game_xml_nodes), date.date()) logger.info(msg) for game in game_xml_nodes: self.process_game(game)