Back to **config.
authorJordi Riera <kender.jr@gmail.com>
Sat, 31 May 2014 14:50:45 +0000 (16:50 +0200)
committerJordi Riera <kender.jr@gmail.com>
Sat, 31 May 2014 14:50:45 +0000 (16:50 +0200)
tweepy/binder.py

index c7f78455cc2ae93e68504305d4146d18bfafec8c..dcf0856b97bd15632edcb1140b80888ff2b083f3 100644 (file)
@@ -16,32 +16,23 @@ from tweepy.models import Model
 re_path_template = re.compile('{\w+}')
 
 
-def bind_api(api,
-             path,
-             use_cache=True,
-             search_api=False,
-             require_auth=False,
-             method='GET',
-             allowed_param=None,
-             payload_list=False,
-             payload_type=None):
-    # common practice to avoid the bug when a list is in arguments.
-    allowed_param = allowed_param or []
+def bind_api(**config):
 
     class APIMethod(object):
 
-        path = path
-        payload_type = payload_type
-        payload_list = payload_list
-        allowed_param = allowed_param
-        method = method
-        require_auth = require_auth
-        search_api = search_api
-        use_cache = use_cache
+        api = config['api']
+        path = config['path']
+        payload_type = config.get('payload_type', None)
+        payload_list = config.get('payload_list', False)
+        allowed_param = config.get('allowed_param', [])
+        method = config.get('method', 'GET')
+        require_auth = config.get('require_auth', False)
+        search_api = config.get('search_api', False)
+        use_cache = config.get('use_cache', True)
         session = requests.Session()
-        api = api
 
         def __init__(self, args, kwargs):
+            api = self.api
             # If authentication is required and no credentials
             # are provided, throw an error.
             if self.require_auth and not api.auth: