# Path: torext/make_settings.py
# class Settings(dict, SingletonMixin):
#     def __init__(self):
#     def __getattr__(self, key):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __str__(self):
#     def add_key_callback(self, key, callback):
# 
# Path: torext/compat.py
# PY3 = sys.version_info.major == 3
# PY2 = sys.version_info.major == 2
#     def unicode_(s, *args):
#     def decode_(s, *args):
#     def bytes_(s):
#     def str_(s):
#     def unicode_(s, *args):
#     def decode_(s, *args):
#     def bytes_(s):
#     def str_(s):


import logging
import hashlib
import requests
import time
from tornado import escape
from tornado import httpclient
from tornado import gen
from tornado.escape import json_decode
from tornado.httputil import url_concat
from tornado.auth import OAuthMixin, OAuth2Mixin
from tornado.util import bytes_type
from torext import settings
from torext.compat import urlencode, quote, urljoin
    _OAUTH_REQUEST_TOKEN_URL = "http://api.twitter.com/oauth/request_token"
    _OAUTH_ACCESS_TOKEN_URL = "http://api.twitter.com/oauth/access_token"
    _OAUTH_AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize"
    _OAUTH_AUTHENTICATE_URL = "http://api.twitter.com/oauth/authenticate"

    def authenticate_redirect(self):
        http = httpclient.AsyncHTTPClient()
        http.fetch(self._oauth_request_token_url(), self.async_callback(
            self._on_request_token, self._OAUTH_AUTHENTICATE_URL, None))

    def twitter_request(self, path, callback, access_token=None,
                        post_args=None, **args):
        # Add the OAuth resource request signature if we have credentials
        # NOTE varibles::
        # :url        used to send request, and bear encoded `args`.
        # :args       keyword-arguments that additionaly added to oauth parameters,
        #             lay on `url`.
        # :post_args  use to judge request method, must be passed as post-data
        # :all_args   as every argument in request take activity
        #             when oauth-parameters is generated, `all_args` contain `args` and `post_args`
        url = "http://api.twitter.com/1" + path + ".json"
        if access_token:
            all_args = {}
            all_args.update(args)
            all_args.update(post_args or {})
            method = "POST" if post_args is not None else "GET"
            oauth = self._oauth_request_parameters(
                url, access_token, all_args, method=method)
            args.update(oauth)
        if args:

# Path: torext/make_settings.py
# class Settings(dict, SingletonMixin):
#     def __init__(self):
#     def __getattr__(self, key):
#     def __getitem__(self, key):
#     def __setitem__(self, key, value):
#     def __str__(self):
#     def add_key_callback(self, key, callback):
# 
# Path: torext/compat.py
# PY3 = sys.version_info.major == 3
# PY2 = sys.version_info.major == 2
#     def unicode_(s, *args):
#     def decode_(s, *args):
#     def bytes_(s):
#     def str_(s):
#     def unicode_(s, *args):
#     def decode_(s, *args):
#     def bytes_(s):
#     def str_(s):


# Path: torext/handlers/oauth.py
import logging
import hashlib
import requests
import time
from tornado import escape
from tornado import httpclient
from tornado import gen
from tornado.escape import json_decode
from tornado.httputil import url_concat
from tornado.auth import OAuthMixin, OAuth2Mixin
from tornado.util import bytes_type
from torext import settings
from torext.compat import urlencode, quote, urljoin

    _OAUTH_REQUEST_TOKEN_URL = "http://api.twitter.com/oauth/request_token"
    _OAUTH_ACCESS_TOKEN_URL = "http://api.twitter.com/oauth/access_token"
    _OAUTH_AUTHORIZE_URL = "http://api.twitter.com/oauth/authorize"
    _OAUTH_AUTHENTICATE_URL = "http://api.twitter.com/oauth/authenticate"

    def authenticate_redirect(self):
        http = httpclient.AsyncHTTPClient()
        http.fetch(self._oauth_request_token_url(), self.async_callback(
            self._on_request_token, self._OAUTH_AUTHENTICATE_URL, None))

    def twitter_request(self, path, callback, access_token=None,
                        post_args=None, **args):
        # Add the OAuth resource request signature if we have credentials
        # NOTE varibles::
        # :url        used to send request, and bear encoded `args`.
        # :args       keyword-arguments that additionaly added to oauth parameters,
        #             lay on `url`.
        # :post_args  use to judge request method, must be passed as post-data
        # :all_args   as every argument in request take activity
        #             when oauth-parameters is generated, `all_args` contain `args` and `post_args`
        url = "http://api.twitter.com/1" + path + ".json"
        if access_token:
            all_args = {}
            all_args.update(args)
            all_args.update(post_args or {})
            method = "POST" if post_args is not None else "GET"
            oauth = self._oauth_request_parameters(
                url, access_token, all_args, method=method)
            args.update(oauth)
        if args:

            url += "?" + urlencode(args)