@@ -31,13 +31,12 @@ class GitHubCore(object):
3131 basic attributes and methods to other sub-classes that are very useful to
3232 have.
3333 """
34+ _ratelimit_resource = 'core'
3435
35- def __init__ (self , json , session = None ):
36+ def __init__ (self , json , session ):
3637 if hasattr (session , 'session' ):
3738 # i.e. session is actually a GitHubCore instance
3839 session = session .session
39- elif session is None :
40- session = GitHubSession ()
4140 self .session = session
4241
4342 # set a sane default
@@ -165,14 +164,14 @@ def __repr__(self):
165164 return repr_string
166165
167166 @classmethod
168- def from_dict (cls , json_dict ):
167+ def from_dict (cls , json_dict , session ):
169168 """Return an instance of this class formed from ``json_dict``."""
170- return cls (json_dict )
169+ return cls (json_dict , session )
171170
172171 @classmethod
173- def from_json (cls , json ):
172+ def from_json (cls , json , session ):
174173 """Return an instance of this class formed from ``json``."""
175- return cls (loads (json ))
174+ return cls (loads (json ), session )
176175
177176 def __eq__ (self , other ):
178177 return self ._uniq == other ._uniq
@@ -305,7 +304,7 @@ def ratelimit_remaining(self):
305304 :returns: int
306305 """
307306 json = self ._json (self ._get (self ._github_url + '/rate_limit' ), 200 )
308- core = json .get ('resources' , {}).get ('core' , {})
307+ core = json .get ('resources' , {}).get (self . _ratelimit_resource , {})
309308 self ._remaining = core .get ('remaining' , 0 )
310309 return self ._remaining
311310
@@ -348,6 +347,10 @@ def refresh(self, conditional=False):
348347 self ._update_attributes (json )
349348 return self
350349
350+ def new_session (self ):
351+ """Helper function to generate a new session"""
352+ return GitHubSession ()
353+
351354
352355class BaseComment (GitHubCore ):
353356
0 commit comments