Skip to content

Commit c44a570

Browse files
1.0.0
See HISTORY.rst for change details!
1 parent 2c0bc00 commit c44a570

11 files changed

+350
-348
lines changed

HISTORY.rst

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. :changelog:
2+
3+
History
4+
-------
5+
6+
1.0.0 (2013-05-23)
7+
++++++++++++++++++
8+
9+
- Changed internal Tumblpy API structure, but Tumblpy functions should still work as they did before
10+
- Updated README with more clear examples
11+
- Added LICENSE
12+
- ``_split_params_and_files`` has been moved to ``helpers.py``
13+
- All ``Tumblpy`` exceptions are found in ``exceptions.py``
14+
- Removed ``pool_maxsize`` from ``Tumblpy.__init__`` because it wasn't being used
15+
- Removed ``timeout`` parameter from all request methods for the time being
16+
- Removed ``TumblpyTimeout`` Exception
17+
- Moved ``callback_url`` parameter from ``Tumblpy.__init__`` to ``get_authentication_tokens``
18+
- All authentication and API calls over HTTPS
19+
- Dropped Python 2.5 support
20+
- Full, transparent Python 3.3 support

LICENSE

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright (c) 2013, Mike Helmick
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include README.rst
1+
include README.rst HISTORY.rst LICENSE

README.rst

+33-52
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Tumblpy
22
=======
33

4+
.. image:: https://pypip.in/d/python-tumblpy/badge.png
5+
:target: https://crate.io/packages/python-tumblpy/
46

57
Tumblpy is a Python library to help interface with `Tumblr v2 REST API <http://www.tumblr.com/docs/en/api/v2>`_ & OAuth
68

@@ -14,12 +16,14 @@ Features
1416
- Edit/delete/reblog posts
1517
- And many more!!
1618
* Photo Uploading
19+
* Transparent *Python 3* Support!
1720

1821

1922
Installation
2023
------------
2124

22-
Installing Tumbply is simple: ::
25+
Installing Tumbply is simple:
26+
::
2327

2428
$ pip install python-tumblpy
2529

@@ -31,54 +35,33 @@ Authorization URL
3135
~~~~~~~~~~~~~~~~~
3236
::
3337

34-
# Without a dynamic callback url
35-
# This will use the callback url specified in your app
36-
37-
# Go to http://www.tumblr.com/oauth/apps and click your
38-
# app to find out your dynamic callback url
39-
t = Tumblpy(app_key = '*your app key*',
40-
app_secret = '*your app secret*')
41-
42-
If you wish to have a dynamic callback url, specify ``callback_url`` when you initiate the class.
43-
44-
::
38+
t = Tumblpy(YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET)
4539

46-
t = Tumblpy(app_key = '*your app key*',
47-
app_secret = '*your app secret*',
48-
callback_url = 'http://example.com/callback/')
49-
50-
::
51-
52-
auth_props = t.get_authentication_tokens()
40+
auth_props = t.get_authentication_tokens(callback_url='http://michaelhelmick.com')
5341
auth_url = auth_props['auth_url']
42+
43+
OAUTH_TOKEN_SECRET = auth_props['oauth_token_secret']
5444
55-
oauth_token = auth_props['oauth_token']
56-
oauth_token_secret = auth_props['oauth_token_secret']
57-
58-
Connect with Tumblr via: % auth_url
45+
print 'Connect with Tumblr via: %s' % auth_url
5946

6047
Once you click "Allow" be sure that there is a URL set up to handle getting finalized tokens and possibly adding them to your database to use their information at a later date.
6148

6249
Handling the Callback
6350
~~~~~~~~~~~~~~~~~~~~~
6451
::
6552

66-
# oauth_token and oauth_token_secret come from the previous step
53+
# OAUTH_TOKEN_SECRET comes from the previous step
6754
# if needed, store those in a session variable or something
6855

69-
t = Tumblpy(app_key = '*your app key*',
70-
app_secret = '*your app secret*',
71-
oauth_token=oauth_token,
72-
oauth_token_secret=oauth_token_secret)
73-
56+
# oauth_verifier and OAUTH_TOKEN are found in your callback url querystring
7457
# In Django, you'd do something like
58+
# OAUTH_TOKEN = request.GET.get('oauth_token')
7559
# oauth_verifier = request.GET.get('oauth_verifier')
76-
77-
# or get the oauth_verifier by visiting auth_url in a browser
78-
# after you authorize the app you'll be redirected to a page (your oauth_callback or Tumblr's 404)
79-
# grab the oauth_verifier from the url of that page
8060

81-
oauth_verifier = *Grab oauth verifier from URL*
61+
62+
t = Tumblpy(YOUR_CONSUMER_KEY, YOUR CONSUMER_SECRET,
63+
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
64+
8265
authorized_tokens = t.get_authorized_tokens(oauth_verifier)
8366
8467
final_oauth_token = authorized_tokens['oauth_token']
@@ -92,28 +75,13 @@ Getting some User information
9275

9376
# Get the final tokens from the database or wherever you have them stored
9477

95-
t = Tumblpy(app_key = '*your app key*',
96-
app_secret = '*your app secret*',
97-
oauth_token=final_tokens['oauth_token'],
98-
oauth_token_secret=final_tokens['oauth_token_secret'])
78+
t = Tumblpy(YOUR_CONSUMER_KEY, YOUR CONSUMER_SECRET,
79+
OAUTH_TOKEN, OAUTH_TOKEN_SECRET)
9980

10081
# Print out the user info, let's get the first blog url...
10182
blog_url = t.post('user/info')
10283
blog_url = blog_url['user']['blogs'][0]['url']
10384

104-
Get a User Avatar URL (No need for authentication for this method)
105-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
106-
::
107-
108-
t = Tumblpy()
109-
avatar = t.get_avatar_url(blog_url='omglegit.tumblr.com', size=128)
110-
print avatar['url']
111-
112-
# OR
113-
114-
avatar = t.get('avatar', blog_url='omglegit.tumblr.com'. extra_endpoints=['128'])
115-
print avatar['url']
116-
11785
Getting posts from a certain blog
11886
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11987
::
@@ -171,11 +139,24 @@ Following a user
171139

172140
# Assume you are using the blog_url and Tumblpy instance from the previous sections
173141
try:
174-
follow = t.post('user/follow', params={'url': 'omglegit.tumblr.com'})
142+
follow = t.post('user/follow', params={'url': 'tumblpy.tumblr.com'})
175143
except TumblpyError:
176144
# if the url given in params is not valid,
177145
# Tumblr will respond with a 404 and Tumblpy will raise a TumblpyError
178146

147+
Get a User Avatar URL *(No need for authentication for this method)*
148+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149+
::
150+
151+
t = Tumblpy()
152+
avatar = t.get_avatar_url(blog_url='tumblpy.tumblr.com', size=128)
153+
print avatar['url']
154+
155+
# OR
156+
157+
avatar = t.get('avatar', blog_url='tumblpy.tumblr.com', extra_endpoints=['128'])
158+
print avatar['url']
159+
179160
Catching errors
180161
~~~~~~~~~~~~~~~
181162
::

setup.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,31 @@
22

33
from setuptools import setup
44

5+
import os
6+
import sys
7+
8+
__author__ = 'Mike Helmick <[email protected]>'
9+
__version__ = '1.0.0'
10+
11+
if sys.argv[-1] == 'publish':
12+
os.system('python setup.py sdist upload')
13+
sys.exit()
14+
515
setup(
616
name='python-tumblpy',
7-
version='0.7.1',
8-
install_requires=['requests>=1.0.4,<1.1.0', 'simplejson', 'requests_oauthlib'],
17+
version='1.0.0',
18+
install_requires=['requests==1.2.2', 'requests_oauthlib==0.3.2'],
919
author='Mike Helmick',
1020
author_email='[email protected]',
11-
license='MIT License',
21+
license=open('LICENSE').read(),
1222
url='https://github.com/michaelhelmick/python-tumblpy/',
1323
keywords='python tumblpy tumblr oauth api',
1424
description='A Python Library to interface with Tumblr v2 REST API & OAuth',
15-
long_description=open('README.rst').read(),
16-
download_url="https://github.com/michaelhelmick/python-tumblpy/zipball/master",
17-
py_modules=["tumblpy"],
25+
long_description=open('README.rst').read() + '\n\n' +
26+
open('HISTORY.rst').read(),
27+
download_url='https://github.com/michaelhelmick/python-tumblpy/zipball/master',
28+
include_package_data=True,
29+
packages=['tumblpy'],
1830
classifiers=[
1931
'Development Status :: 4 - Beta',
2032
'Intended Audience :: Developers',
@@ -23,7 +35,4 @@
2335
'Topic :: Communications :: Chat',
2436
'Topic :: Internet'
2537
],
26-
dependency_links=[
27-
'https://github.com/requests/requests-oauthlib/tarball/master#egg=requests_oauthlib-0.2.0'
28-
],
2938
)

0 commit comments

Comments
 (0)