perceval/backends/core/github.py
def _choose_best_api_token(self):
        """Check all API tokens defined and choose one with most remaining API points"""

        # Return if no tokens given
        if self.n_tokens == 0:
            return

        # If multiple tokens given, choose best
        token_idx = 0
        if self.n_tokens > 1:
            remainings = self._get_tokens_rate_limits()
            token_idx = remainings.index(max(remainings))
            logger.debug("Remaining API points: {}, choosen index: {}".format(remainings, token_idx))

        # If we have any tokens - use best of them
        self.current_token = self.tokens[token_idx]
        self.session.headers.update({'Authorization': 'token ' + self.current_token})
        # Update rate limit data for the current token
        self._update_current_rate_limit()
def _choose_best_api_token(self):
        # Return if no tokens given
        if self.n_tokens == 0:
            return

        # If multiple tokens given, choose best
        token_idx = 0
        if self.n_tokens > 1:
            remainings = self._get_tokens_rate_limits()
            token_idx = remainings.index(max(remainings))
            logger.debug("Remaining API points: {}, choosen index: {}".format(remainings, token_idx))

        # If we have any tokens - use best of them
        self.current_token = self.tokens[token_idx]
        self.session.headers.update({'Authorization': 'token ' + self.current_token})
        # Update rate limit data for the current token
        self._update_current_rate_limit()
def _choose_best_api_token ( self ) : # Return if no tokens given if self . n_tokens == 0 : return # If multiple tokens given, choose best token_idx = 0 if self . n_tokens > 1 : remainings = self . _get_tokens_rate_limits ( ) token_idx = remainings . index ( max ( remainings ) ) logger . debug ( "Remaining API points: {}, choosen index: {}" . format ( remainings , token_idx ) ) # If we have any tokens - use best of them self . current_token = self . tokens [ token_idx ] self . session . headers . update ( { 'Authorization' : 'token ' + self . current_token } ) # Update rate limit data for the current token self . _update_current_rate_limit ( )
Check all API tokens defined and choose one with most remaining API points
Check all API tokens defined and choose one with most remaining API points