Skip to content

Instantly share code, notes, and snippets.

Last active September 22, 2019 17:06
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Script for an Alfred shortcut to open PyPI docs
#!/usr/bin/env python
# -*- encoding: utf-8
Try to open the documentation for a Python package, or the PyPI page if
it can't be found.
import json
import sys
import webbrowser
from urllib.request import urlopen
except ImportError: # Python 2
from urllib2 import urlopen
package_name = sys.argv[1]
resp = urlopen("" % package_name)
data = json.load(resp)
docs_url = data["info"]["project_urls"]["Documentation"]
except KeyError:
docs_url = "" % package_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment