Merge pull request #70 from michaelhelmick/master
Passing kwargs to function now works. Urgent bug fix.
This commit is contained in:
commit
9153fdf41b
2 changed files with 6 additions and 5 deletions
2
setup.py
2
setup.py
|
|
@ -4,7 +4,7 @@ from setuptools import setup
|
||||||
from setuptools import find_packages
|
from setuptools import find_packages
|
||||||
|
|
||||||
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
__author__ = 'Ryan McGrath <ryan@venodesigns.net>'
|
||||||
__version__ = '1.5.1'
|
__version__ = '1.5.2'
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
# Basic package information.
|
# Basic package information.
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
||||||
__version__ = "1.5.1"
|
__version__ = "1.5.2"
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
import re
|
import re
|
||||||
|
|
@ -210,7 +210,7 @@ class Twython(object):
|
||||||
def _constructFunc(self, api_call, **kwargs):
|
def _constructFunc(self, api_call, **kwargs):
|
||||||
# Go through and replace any mustaches that are in our API url.
|
# Go through and replace any mustaches that are in our API url.
|
||||||
fn = api_table[api_call]
|
fn = api_table[api_call]
|
||||||
base = re.sub(
|
url = re.sub(
|
||||||
'\{\{(?P<m>[a-zA-Z_]+)\}\}',
|
'\{\{(?P<m>[a-zA-Z_]+)\}\}',
|
||||||
# The '1' here catches the API version. Slightly hilarious.
|
# The '1' here catches the API version. Slightly hilarious.
|
||||||
lambda m: "%s" % kwargs.get(m.group(1), '1'),
|
lambda m: "%s" % kwargs.get(m.group(1), '1'),
|
||||||
|
|
@ -221,13 +221,14 @@ class Twython(object):
|
||||||
if not method in ('get', 'post', 'delete'):
|
if not method in ('get', 'post', 'delete'):
|
||||||
raise TwythonError('Method must be of GET, POST or DELETE')
|
raise TwythonError('Method must be of GET, POST or DELETE')
|
||||||
|
|
||||||
|
myargs = {}
|
||||||
if method == 'get':
|
if method == 'get':
|
||||||
myargs = ['%s=%s' % (key, value) for (key, value) in kwargs.iteritems()]
|
url = '%s?%s' % (url, urllib.urlencode(kwargs))
|
||||||
else:
|
else:
|
||||||
myargs = kwargs
|
myargs = kwargs
|
||||||
|
|
||||||
func = getattr(self.client, method)
|
func = getattr(self.client, method)
|
||||||
response = func(base, data=myargs)
|
response = func(url, data=myargs)
|
||||||
|
|
||||||
return simplejson.loads(response.content.decode('utf-8'))
|
return simplejson.loads(response.content.decode('utf-8'))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue