Re-naming
This commit is contained in:
@@ -36,7 +36,7 @@ from . import packages
|
||||
from .packages import praw
|
||||
from .config import Config, copy_default_config, copy_default_mailcap
|
||||
from .theme import Theme
|
||||
from .oauth import OAuthHelper, OAuthRateLimitHandler
|
||||
from .oauth import OAuthHelper, OAuthRateLimiter
|
||||
from .terminal import Terminal
|
||||
from .objects import curses_session, patch_webbrowser
|
||||
from .subreddit_page import SubredditPage
|
||||
@@ -174,11 +174,10 @@ def main():
|
||||
term = Terminal(stdscr, config, theme)
|
||||
|
||||
with term.loader('Initializing', catch_exception=False):
|
||||
handler = OAuthRateLimitHandler()
|
||||
reddit = praw.Reddit(user_agent=user_agent,
|
||||
decode_html_entities=False,
|
||||
disable_update_check=True,
|
||||
handler=handler)
|
||||
handler=OAuthRateLimiter())
|
||||
|
||||
# Authorize on launch if the refresh token is present
|
||||
oauth = OAuthHelper(reddit, term, config)
|
||||
|
||||
@@ -231,6 +231,12 @@ class OAuthHelper(object):
|
||||
|
||||
|
||||
def fix_cache(func):
|
||||
"""
|
||||
This is a shim around PRAW's 30 second page cache that attempts
|
||||
to address broken behavior that hasn't been fixed because PRAW 3
|
||||
is deprecated.
|
||||
"""
|
||||
|
||||
def wraps(self, _cache_key, _cache_ignore, *args, **kwargs):
|
||||
if _cache_key:
|
||||
# Pop the request's session cookies from the cache key.
|
||||
@@ -249,7 +255,7 @@ def fix_cache(func):
|
||||
return wraps
|
||||
|
||||
|
||||
class OAuthRateLimitHandler(DefaultHandler):
|
||||
class OAuthRateLimiter(DefaultHandler):
|
||||
"""Custom PRAW request handler for rate-limiting requests.
|
||||
|
||||
This is an alternative to PRAW 3's DefaultHandler that uses
|
||||
|
||||
@@ -12,7 +12,7 @@ from vcr import VCR
|
||||
from six.moves.urllib.parse import urlparse, parse_qs
|
||||
from six.moves.BaseHTTPServer import HTTPServer
|
||||
|
||||
from rtv.oauth import OAuthHelper, OAuthHandler, OAuthRateLimitHandler
|
||||
from rtv.oauth import OAuthHelper, OAuthHandler, OAuthRateLimiter
|
||||
from rtv.config import Config
|
||||
from rtv.packages import praw
|
||||
from rtv.terminal import Terminal
|
||||
@@ -39,7 +39,7 @@ for name in ['vcr.matchers', 'vcr.stubs']:
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption('--record-mode', dest='record_mode', default='none')
|
||||
parser.addoption('--refresh-token', dest='refresh_token',
|
||||
default='tests/refresh-token')
|
||||
default='~/.config/rtv/refresh-token')
|
||||
|
||||
|
||||
class MockStdscr(mock.MagicMock):
|
||||
@@ -180,7 +180,7 @@ def reddit(vcr, request):
|
||||
|
||||
with vcr.use_cassette(cassette_name):
|
||||
with patch('rtv.packages.praw.Reddit.get_access_information'):
|
||||
handler = OAuthRateLimitHandler()
|
||||
handler = OAuthRateLimiter()
|
||||
|
||||
reddit = praw.Reddit(user_agent='rtv test suite',
|
||||
decode_html_entities=False,
|
||||
|
||||
Reference in New Issue
Block a user