# 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
                url, access_token, all_args, method=method)
            args.update(oauth)
        http = httpclient.AsyncHTTPClient()
        callback = self.async_callback(self._on_douban_request, callback)

        if post_args is not None:
            # douban says that they can't deal request properly
            # when oauth parameters passing in post data,
            # instead, passing it in HTTP Headers
            # NOTE that `url` here is different from `url` in below fetch function:
            # it is plain, doesn't contain encoded args.
            http.fetch(url, method="POST",
                       headers=args,
                       body=post_args,
                       callback=callback)
        else:
            if args:
                url += "?" + urlencode(args)
            http.fetch(url, callback=callback)

    def _on_douban_request(self, callback, response):
        if response.error:
            logging.warning("Error response %s fetching %s", response.error,
                            response.request.url)
            callback(None)
            return
        callback(escape.json_decode(response.body))

    def _oauth_consumer_token(self):
        return dict(key=settings.networks['douban']['consumer_key'],

# 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

                url, access_token, all_args, method=method)
            args.update(oauth)
        http = httpclient.AsyncHTTPClient()
        callback = self.async_callback(self._on_douban_request, callback)

        if post_args is not None:
            # douban says that they can't deal request properly
            # when oauth parameters passing in post data,
            # instead, passing it in HTTP Headers
            # NOTE that `url` here is different from `url` in below fetch function:
            # it is plain, doesn't contain encoded args.
            http.fetch(url, method="POST",
                       headers=args,
                       body=post_args,
                       callback=callback)
        else:
            if args:
                url += "?" + urlencode(args)
            http.fetch(url, callback=callback)

    def _on_douban_request(self, callback, response):
        if response.error:
            logging.warning("Error response %s fetching %s", response.error,
                            response.request.url)
            callback(None)
            return
        callback(escape.json_decode(response.body))

    def _oauth_consumer_token(self):
        return dict(key=settings.networks['douban']['consumer_key'],

                    secret=settings.networks['douban']['consumer_secret'])