def _get_previous_matchups(): today = datetime.date.today() for i in range(1, 10): filename = _create_file_path(today + datetime.timedelta(days=-i)) if os.path.isfile(filename): print 'Found recent data: {}'.format(filename) with open(filename, 'r') as f: return [Matchup.from_json(jobj) for jobj in json.load(f)] print 'Found no recent data' return []
import json from matchup import Matchup from emailer import send_email with open('history/2017-05-02.json', 'r') as f: games = [Matchup.from_json(g) for g in json.load(f)] with open('history/2017-season.json', 'r') as f: totals = json.load(f) send_email(games, games, totals, { 'email_template': './email_template.html', 'email_to': '*****@*****.**', 'email_from': '*****@*****.**', 'email_from': '*****@*****.**', 'email_password': '******', 'email_cc': ['*****@*****.**', '*****@*****.**'], })
def load_matchups(file): with open(file, 'r') as f: return [Matchup.from_json(m) for m in json.load(f)]