#122: proxy support for intersphinx

This commit is contained in:
Sebastian Wiesner 2009-03-19 15:49:03 +01:00
parent 5469dfe4e6
commit 73942678c8
2 changed files with 10 additions and 2 deletions

View File

@ -60,6 +60,9 @@ linking:
``http://docs.python.org/dev``. It is up to you to update the inventory file
as new objects are added to the Python documentation.
When fetching remote inventory files, proxy settings will be read from
the ``$HTTP_PROXY`` environment variable.
.. confval:: intersphinx_cache_limit
The maximum number of days to cache remote inventories. The default is

View File

@ -25,7 +25,7 @@
"""
import time
import urllib
import urllib2
import posixpath
from os import path
@ -34,6 +34,11 @@ from docutils import nodes
from sphinx.builders.html import INVENTORY_FILENAME
urllib2.install_opener(urllib2.build_opener(
urllib2.ProxyHandler(), urllib2.HTTPRedirectHandler(),
urllib2.HTTPHandler(), urllib2.HTTPSHandler()))
def fetch_inventory(app, uri, inv):
"""Fetch, parse and return an intersphinx inventory file."""
invdata = {}
@ -42,7 +47,7 @@ def fetch_inventory(app, uri, inv):
localuri = uri.find('://') == -1
try:
if inv.find('://') != -1:
f = urllib.urlopen(inv)
f = urllib2.urlopen(inv)
else:
f = open(path.join(app.srcdir, inv))
except Exception, err: