@@ -0,0 +1,1784 @@
+import urllib2 as url%0Aimport os%0Aimport sys%0Afrom datetime import date%0Aimport gzip%0A%0Adef run():%0A    '''%0A    Update local game data%0A    '''%0A    year = date.today().year%0A    month = date.today().month%0A    day = date.today().day%0A    for i in range(2012, year+1):%0A        for x in range(1, 13):%0A            monthstr = str(x).zfill(2)%0A            loading = False%0A            for y in range(1, 31):%0A                if i == year and x %3E= month and y %3E= day:%0A                    break%0A                daystr = str(y).zfill(2)%0A                filename = %22gameday-data/year_%22+str(i)+%22/month_%22+monthstr+%22/day_%22+daystr+%22/scoreboard.xml.gz%22%0A                file = os.path.join(os.path.dirname(__file__), filename)%0A                if not os.path.isfile(file):%0A                    try:%0A                        data = url.urlopen(%22http://gd2.mlb.com/components/game/mlb/year_%22+str(i)+%22/month_%22+monthstr+%22/day_%22+daystr+%22/scoreboard.xml%22)%0A                        sys.stdout.write('Loading games for %25s-%25d (%2500.2f%25%25) %5Cr' %25 (monthstr, i, y/31.0*100))%0A                        sys.stdout.flush()%0A                        loading = True%0A                        response = data.read()%0A                        dirn = %22gameday-data/year_%22+str(i)+%22/month_%22+monthstr+%22/day_%22+daystr%0A                        dirname = os.path.join(os.path.dirname(__file__), dirn)%0A                        if not os.path.exists(dirname):%0A                            os.makedirs(dirname)%0A                        with gzip.open(file, %22w%22) as f:%0A                            f.write(response)%0A                    except url.HTTPError:%0A                        pass%0A            if loading == True:%0A                sys.stdout.write('Loading games for %25s-%25d (100.00%25%25)%5Cn' %25 (monthstr, i))%0A                sys.stdout.flush()%0A    print %22Complete%22

Update local game data