@@ -174,12 +174,12 @@ def __init__(self,
174174 self .base_url = 'https://api.twitter.com/1.1'
175175 else :
176176 self .base_url = base_url
177-
177+
178178 if stream_url is None :
179179 self .stream_url = 'https://stream.twitter.com/1.1'
180180 else :
181181 self .stream_url = stream_url
182-
182+
183183 if upload_url is None :
184184 self .upload_url = 'https://upload.twitter.com/1.1'
185185 else :
@@ -233,7 +233,7 @@ def SetCredentials(self,
233233 access_token_key , access_token_secret ]
234234
235235 if all (auth_list ):
236- self .__auth = OAuth1 (consumer_key , consumer_secret ,
236+ self .__auth = OAuth1 (consumer_key , consumer_secret ,
237237 access_token_key , access_token_secret )
238238
239239 self ._config = None
@@ -1127,7 +1127,7 @@ def GetUserRetweets(self,
11271127 '''
11281128 return self .GetUserTimeline (since_id = since_id , count = count , max_id = max_id , trim_user = trim_user , exclude_replies = True , include_rts = True )
11291129
1130- def GetReplies (self ,
1130+ def GetReplies (self ,
11311131 since_id = None ,
11321132 count = None ,
11331133 max_id = None ,
@@ -1509,7 +1509,7 @@ def GetFriendIDs(self,
15091509 else :
15101510 break
15111511 sec = self .GetSleepTime ('/friends/ids' )
1512- time .sleep (sec )
1512+ time .sleep (sec )
15131513
15141514 return result
15151515
@@ -1580,7 +1580,7 @@ def GetFollowerIDs(self,
15801580 else :
15811581 break
15821582 sec = self .GetSleepTime ('/followers/ids' )
1583- time .sleep (sec )
1583+ time .sleep (sec )
15841584
15851585 return result
15861586
@@ -1694,7 +1694,7 @@ def GetFollowers(self,
16941694 else :
16951695 cursor = next_cursor
16961696 sec = self .GetSleepTime ('/followers/list' )
1697- time .sleep (sec )
1697+ time .sleep (sec )
16981698
16991699 return result
17001700
@@ -2680,7 +2680,7 @@ def GetListTimeline(self,
26802680 since_id:
26812681 Returns results with an ID greater than (that is, more recent than)
26822682 the specified ID. There are limits to the number of Tweets which
2683- can be accessed through the API.
2683+ can be accessed through the API.
26842684 If the limit of Tweets has occurred since the since_id, the since_id
26852685 will be forced to the oldest ID available. [Optional]
26862686 max_id:
@@ -2820,7 +2820,7 @@ def GetListMembers(self,
28202820 else :
28212821 break
28222822 sec = self .GetSleepTime ('/followers/list' )
2823- time .sleep (sec )
2823+ time .sleep (sec )
28242824
28252825 return result
28262826
@@ -3215,10 +3215,10 @@ def GetUserStream(self,
32153215 '''Returns the data from the user stream.
32163216
32173217 Args:
3218- replies:
3218+ replies:
32193219 Specifies whether to return additional @replies in the stream.
32203220 Defaults to 'all'.
3221- withuser:
3221+ withuser:
32223222 Specifies whether to return information for just the authenticating
32233223 user, or include messages from accounts the user follows. [Optional]
32243224 track:
@@ -3378,7 +3378,7 @@ def GetAverageSleepTime(self, resources):
33783378 imposed for the currently authenticated user.
33793379
33803380 Returns:
3381- The average seconds that the api must have to sleep
3381+ The average seconds that the api must have to sleep
33823382 '''
33833383 if resources [0 ] == '/' :
33843384 resources = resources [1 :]
@@ -3405,7 +3405,7 @@ def GetSleepTime(self, resources):
34053405 imposed for the currently authenticated user.
34063406
34073407 Returns:
3408- The minimum seconds that the api must have to sleep before query again
3408+ The minimum seconds that the api must have to sleep before query again
34093409 '''
34103410 if resources [0 ] == '/' :
34113411 resources = resources [1 :]
@@ -3422,7 +3422,10 @@ def GetSleepTime(self, resources):
34223422 utc_stuct = utc_now .timetuple ()
34233423 current_time = timegm (utc_stuct )
34243424 delta = reset_time - current_time
3425- return delta
3425+ if delta < 0 :
3426+ return 0
3427+ else :
3428+ return delta
34263429 else :
34273430 return 0
34283431
@@ -3554,7 +3557,7 @@ def _CheckForTwitterError(self, data):
35543557 raise TwitterError (data ['errors' ])
35553558
35563559 def _RequestUrl (self , url , verb , data = None ):
3557- '''Request a url.
3560+ '''Request a url.
35583561
35593562 Args:
35603563 url:
@@ -3617,7 +3620,7 @@ def _RequestStream(self, url, verb, data=None):
36173620 A twitter stream.
36183621 '''
36193622 if verb == 'POST' :
3620- try :
3623+ try :
36213624 return requests .post (url , data = data , stream = True ,
36223625 auth = self .__auth ,
36233626 timeout = self ._timeout
0 commit comments