Resolve Merge
This commit is contained in:
commit
13b55324c9
4 changed files with 42 additions and 27 deletions
|
|
@ -1,8 +0,0 @@
|
||||||
from twython import Twython
|
|
||||||
|
|
||||||
# Getting the public timeline requires no authentication, huzzah
|
|
||||||
twitter = Twython()
|
|
||||||
public_timeline = twitter.getPublicTimeline()
|
|
||||||
|
|
||||||
for tweet in public_timeline:
|
|
||||||
print tweet["text"]
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -16,7 +16,7 @@ setup(
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
|
|
||||||
# Package dependencies.
|
# Package dependencies.
|
||||||
install_requires=['simplejson', 'requests>=0.13.9'],
|
install_requires=['simplejson', 'requests>=0.14.1'],
|
||||||
|
|
||||||
# Metadata for PyPI.
|
# Metadata for PyPI.
|
||||||
author='Ryan McGrath',
|
author='Ryan McGrath',
|
||||||
|
|
|
||||||
|
|
@ -163,6 +163,10 @@ api_table = {
|
||||||
'url': '/account/totals.json',
|
'url': '/account/totals.json',
|
||||||
'method': 'GET',
|
'method': 'GET',
|
||||||
},
|
},
|
||||||
|
'removeProfileBanner': {
|
||||||
|
'url': '/account/remove_profile_banner.json',
|
||||||
|
'method': 'POST',
|
||||||
|
},
|
||||||
|
|
||||||
# Favorites methods
|
# Favorites methods
|
||||||
'getFavorites': {
|
'getFavorites': {
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,6 @@ class Twython(object):
|
||||||
'content': content,
|
'content': content,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# wrap the json loads in a try, and defer an error
|
# wrap the json loads in a try, and defer an error
|
||||||
# why? twitter will return invalid json with an error code in the headers
|
# why? twitter will return invalid json with an error code in the headers
|
||||||
json_error = False
|
json_error = False
|
||||||
|
|
@ -211,7 +210,7 @@ class Twython(object):
|
||||||
retry_after=response.headers.get('retry-after'))
|
retry_after=response.headers.get('retry-after'))
|
||||||
|
|
||||||
# if we have a json error here, then it's not an official TwitterAPI error
|
# if we have a json error here, then it's not an official TwitterAPI error
|
||||||
if json_error:
|
if json_error and not response.status_code in (200, 201, 202):
|
||||||
raise TwythonError('Response was not valid JSON, unable to decode.')
|
raise TwythonError('Response was not valid JSON, unable to decode.')
|
||||||
|
|
||||||
return content
|
return content
|
||||||
|
|
@ -400,8 +399,24 @@ class Twython(object):
|
||||||
for tweet in self.searchGen(search_query, **kwargs):
|
for tweet in self.searchGen(search_query, **kwargs):
|
||||||
yield tweet
|
yield tweet
|
||||||
|
|
||||||
|
def bulkUserLookup(self, **kwargs):
|
||||||
|
"""Stub for a method that has been deprecated, kept for now to raise errors
|
||||||
|
properly if people are relying on this (which they are...).
|
||||||
|
"""
|
||||||
|
warnings.warn(
|
||||||
|
"This function has been deprecated. Please migrate to .lookupUser() - params should be the same.",
|
||||||
|
DeprecationWarning,
|
||||||
|
stacklevel=2
|
||||||
|
)
|
||||||
|
|
||||||
# The following methods are apart from the other Account methods,
|
# The following methods are apart from the other Account methods,
|
||||||
# because they rely on a whole multipart-data posting function set.
|
# because they rely on a whole multipart-data posting function set.
|
||||||
|
|
||||||
|
## Media Uploading functions ##############################################
|
||||||
|
|
||||||
|
def _media_update(self, url, file_, **params):
|
||||||
|
return self.post(url, params=params, files=file_)
|
||||||
|
|
||||||
def updateProfileBackgroundImage(self, file_, tile=True, version=1):
|
def updateProfileBackgroundImage(self, file_, tile=True, version=1):
|
||||||
"""Updates the authenticating user's profile background image.
|
"""Updates the authenticating user's profile background image.
|
||||||
|
|
||||||
|
|
@ -417,16 +432,6 @@ class Twython(object):
|
||||||
{'image': (file_, open(file_, 'rb'))},
|
{'image': (file_, open(file_, 'rb'))},
|
||||||
**{'tile': tile})
|
**{'tile': tile})
|
||||||
|
|
||||||
def bulkUserLookup(self, **kwargs):
|
|
||||||
"""Stub for a method that has been deprecated, kept for now to raise errors
|
|
||||||
properly if people are relying on this (which they are...).
|
|
||||||
"""
|
|
||||||
warnings.warn(
|
|
||||||
"This function has been deprecated. Please migrate to .lookupUser() - params should be the same.",
|
|
||||||
DeprecationWarning,
|
|
||||||
stacklevel=2
|
|
||||||
)
|
|
||||||
|
|
||||||
def updateProfileImage(self, file_, version=1):
|
def updateProfileImage(self, file_, version=1):
|
||||||
"""Updates the authenticating user's profile image (avatar).
|
"""Updates the authenticating user's profile image (avatar).
|
||||||
|
|
||||||
|
|
@ -453,8 +458,22 @@ class Twython(object):
|
||||||
{'media': (file_, open(file_, 'rb'))},
|
{'media': (file_, open(file_, 'rb'))},
|
||||||
**params)
|
**params)
|
||||||
|
|
||||||
def _media_update(self, url, file_, **params):
|
def updateProfileBannerImage(self, file_, version=1, **params):
|
||||||
return self.post(url, params=params, files=file_)
|
"""Updates the users profile banner
|
||||||
|
|
||||||
|
:param file_: (required) A string to the location of the file
|
||||||
|
:param version: (optional) A number, default 1 because that's the
|
||||||
|
only API version Twitter has now
|
||||||
|
|
||||||
|
**params - You may pass items that are taken in this doc
|
||||||
|
(https://dev.twitter.com/docs/api/1/post/account/update_profile_banner)
|
||||||
|
"""
|
||||||
|
url = 'https://api.twitter.com/%d/account/update_profile_banner.json' % version
|
||||||
|
return self._media_update(url,
|
||||||
|
{'banner': (file_, open(file_, 'rb'))},
|
||||||
|
**params)
|
||||||
|
|
||||||
|
###########################################################################
|
||||||
|
|
||||||
def getProfileImageUrl(self, username, size='normal', version=1):
|
def getProfileImageUrl(self, username, size='normal', version=1):
|
||||||
"""Gets the URL for the user's profile image.
|
"""Gets the URL for the user's profile image.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue