Skip to content

Commit

Permalink
Merge pull request #28 from russodanielp/windows-fix
Browse files Browse the repository at this point in the history
wrote code to unzip .gz files on windows systems
Fixes #24
  • Loading branch information
panzarino authored Apr 12, 2017
2 parents d1f430a + 9f851df commit b11e90f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mlbgame/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

import os
import sys

try:
from urllib.request import urlopen
Expand All @@ -23,6 +24,16 @@ def get_scoreboard(year, month, day):
file = os.path.join(os.path.dirname(__file__), filename)
# check if file exits
if os.path.isfile(file):
if sys.platform == 'win32':
file_unzipped = file[:-3]
if not os.path.exists(file_unzipped):
import gzip
f_gz = gzip.open(file, 'rb')
f = open(file_unzipped, 'wb')
f.write(f_gz.read())
f.close()
f_gz.close()
file = file_unzipped
data = file
else:
# get data if file does not exist
Expand Down

0 comments on commit b11e90f

Please sign in to comment.