2424from pybaseball .utils import get_text_file
2525from datetime import datetime
2626from io import StringIO
27- from github import Github
27+ from github import Auth , Github
2828import os
2929from getpass import getuser , getpass
3030from github .GithubException import RateLimitExceededException
@@ -131,7 +131,7 @@ def events(season, type='regular', export_dir='.'):
131131 "the valid types are: 'regular', 'post', and 'asg'." )
132132
133133 try :
134- g = Github (GH_TOKEN )
134+ g = Github (auth = Auth . Token ( GH_TOKEN )) if GH_TOKEN else Github ( )
135135 repo = g .get_repo ('chadwickbureau/retrosheet' )
136136 season_folder = [f .path [f .path .rfind ('/' )+ 1 :] for f in repo .get_contents (f'seasons/{ season } ' )]
137137 season_events = [t for t in season_folder if t .endswith (file_extension )]
@@ -156,7 +156,7 @@ def rosters(season):
156156 GH_TOKEN = os .getenv ('GH_TOKEN' , '' )
157157
158158 try :
159- g = Github (GH_TOKEN )
159+ g = Github (auth = Auth . Token ( GH_TOKEN )) if GH_TOKEN else Github ( )
160160 repo = g .get_repo ('chadwickbureau/retrosheet' )
161161 season_folder = [f .path [f .path .rfind ('/' )+ 1 :] for f in repo .get_contents (f'seasons/{ season } ' )]
162162 rosters = [t for t in season_folder if t .endswith ('.ROS' )]
@@ -179,7 +179,7 @@ def _roster(team, season, checked = False):
179179 GH_TOKEN = os .getenv ('GH_TOKEN' , '' )
180180
181181 if not checked :
182- g = Github (GH_TOKEN )
182+ g = Github (auth = Auth . Token ( GH_TOKEN )) if GH_TOKEN else Github ( )
183183 try :
184184 repo = g .get_repo ('chadwickbureau/retrosheet' )
185185 season_folder = [f .path [f .path .rfind ('/' )+ 1 :] for f in repo .get_contents (f'seasons/{ season } ' )]
@@ -213,7 +213,7 @@ def schedules(season):
213213 """
214214 GH_TOKEN = os .getenv ('GH_TOKEN' , '' )
215215 # validate input
216- g = Github (GH_TOKEN )
216+ g = Github (auth = Auth . Token ( GH_TOKEN )) if GH_TOKEN else Github ( )
217217 repo = g .get_repo ('chadwickbureau/retrosheet' )
218218 season_folder = [f .path [f .path .rfind ('/' )+ 1 :] for f in repo .get_contents (f'seasons/{ season } ' )]
219219 file_name = f'{ season } schedule.csv'
@@ -231,7 +231,7 @@ def season_game_logs(season):
231231 """
232232 GH_TOKEN = os .getenv ('GH_TOKEN' , '' )
233233 # validate input
234- g = Github (GH_TOKEN )
234+ g = Github (auth = Auth . Token ( GH_TOKEN )) if GH_TOKEN else Github ( )
235235 repo = g .get_repo ('chadwickbureau/retrosheet' )
236236 season_folder = [f .path [f .path .rfind ('/' )+ 1 :] for f in repo .get_contents (f'seasons/{ season } ' )]
237237 gamelog_file_name = f'GL{ season } .TXT'
0 commit comments