From d2823bf6b7385a6deec46f29ca1d6d7ace19226c Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Thu, 31 Mar 2011 04:48:54 -0400 Subject: [PATCH] rely on requests --- gistapi/core.py | 4 ++-- setup.py | 35 +++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/gistapi/core.py b/gistapi/core.py index 85e18ee..d9bed3b 100644 --- a/gistapi/core.py +++ b/gistapi/core.py @@ -35,7 +35,7 @@ u'Great Stuff.' import cStringIO import os.path -import urllib2 +import requests from datetime import datetime try: @@ -97,7 +97,7 @@ class Gist(object): else: # Fetch Gist metadata _meta_url = GIST_JSON % self.id - _meta = json.load(urllib2.urlopen(_meta_url))['gists'][0] + _meta = json.loads(requests.get(_meta_url).content)['gists'][0] for key, value in _meta.iteritems(): diff --git a/setup.py b/setup.py index bd198b7..6f0323c 100644 --- a/setup.py +++ b/setup.py @@ -9,36 +9,39 @@ from distutils.core import setup def publish(): - """Publish to PyPi""" os.system("python setup.py sdist upload") + if sys.argv[-1] == "publish": publish() sys.exit() + -required = [] +required = ['requests'] + if sys.version_info[:2] < (2,6): required.append('simplejson') -setup(name='gistapi', - version=gistapi.__version__, - description='Python wrapper for Gist API', - long_description=open('README.rst').read() + '\n\n' + - open('HISTORY.rst').read(), - author='Kenneth Reitz', - author_email='me@kennethreitz.com', - url='http://github.com/kennethreitz/gistapi.py', - packages=['gistapi'], - install_requires=required, - license='MIT', - classifiers=( + +setup( + name='gistapi', + version=gistapi.__version__, + description='Python wrapper for Gist API', + long_description=open('README.rst').read() + '\n\n' + open('HISTORY.rst').read(), + author='Kenneth Reitz', + author_email='me@kennethreitz.com', + url='http://github.com/kennethreitz/gistapi.py', + packages=['gistapi'], + install_requires=required, + license='MIT', + classifiers=( "Development Status :: 4 - Beta", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", - ) - ) + ) +)