How to use the riotwatcher.Handlers.LimitCount function in riotwatcher

To help you get started, we’ve selected a few riotwatcher examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pseudonym117 / Riot-Watcher / riotwatcher / Handlers / RateLimitHeaders.py View on Github external
method_lim = headers.get('X-Method-Rate-Limit')

        if method_lim is not None:
            limit_strings = method_lim.split(',')
            self._method_rate_limit = [LimitCount(lim_str) for lim_str in limit_strings]

        self._method_rate_limit_count = None
        method_lim_count = headers.get('X-Method-Rate-Limit-Count')

        if method_lim_count is not None:
            method_limit_strings = method_lim_count.split(',')
            if last_headers is not None and last_headers.method_rate_limit_count is not None:
                strings_with_old_limits = zip(method_limit_strings, last_headers.method_rate_limit_count)

                self._method_rate_limit_count = [
                    LimitCount(lim_str, last_limit=old_limit)
                    for lim_str, old_limit in strings_with_old_limits
                ]
            else:
                self._method_rate_limit_count = [LimitCount(lim_str) for lim_str in method_limit_strings]
github pseudonym117 / Riot-Watcher / riotwatcher / Handlers / RateLimitHeaders.py View on Github external
:param last_headers: previous RateLimitHeaders object, used to determine
            what the actual start time of each rate limit is
        """
        self._time = datetime.datetime.now()

        self._rate_limit_type = headers.get('X-Rate-Limit-Type')

        retry_after = headers.get('Retry-After')
        self._retry_after = int(retry_after) if retry_after is not None else None

        self._app_rate_limit = None
        app_lim = headers.get('X-App-Rate-Limit')

        if app_lim is not None:
            limit_strings = app_lim.split(',')
            self._app_rate_limit = [LimitCount(lim_str) for lim_str in limit_strings]

        self._app_rate_limit_count = None
        app_lim_count = headers.get('X-App-Rate-Limit-Count')

        if app_lim_count is not None:
            limit_strings = app_lim_count.split(',')
            if last_headers is not None and last_headers.app_rate_limit_count is not None:
                strings_with_old_limits = zip(limit_strings, last_headers.app_rate_limit_count)

                self._app_rate_limit_count = [
                    LimitCount(lim_str, last_limit=old_limit) for lim_str, old_limit in strings_with_old_limits
                ]
            else:
                self._app_rate_limit_count = [LimitCount(lim_str) for lim_str in limit_strings]

        self._method_rate_limit = None