Description: use local objects.inv where possible
 Upstream uses intersphinx mappings that fetch the objects.inv for python and
 python-mock by HTTP from a remote host. Using the local objects.inv from
 python and python-mock enables the package to build without network connection.
Author: Michael Fladischer <fladi@debian.org>
Last-Update: 2013-12-03
Forwarded: not-needed

--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -32,11 +32,23 @@
     'sphinx.ext.viewcode',
 ]
 
-intersphinx_mapping = {
-    'python': ('http://docs.python.org/2/', 'http://docs.python.org/2/objects.inv'),
-    'ldap': ('http://python-ldap.org/doc/html/', None),
-    'mock': ('http://www.voidspace.org.uk/python/mock/', None),
-}
+def check_object_path(key, url, path):
+    if os.path.isfile(path):
+        return {key: (url, path)}
+    return {}
+
+intersphinx_mapping = {}
+intersphinx_mapping.update(check_object_path('python',
+                                            'http://docs.python.org/',
+                                            '/usr/share/doc/python'
+                                              + '.'.join([str(x) for x in sys.version_info[0:2]])
+                                              + '/html/objects.inv'))
+intersphinx_mapping.update(check_object_path('ldap',
+                                             'http://python-ldap.org/doc/html/',
+                                             ''))
+intersphinx_mapping.update(check_object_path('mock',
+                                             'http://www.voidspace.org.uk/python/mock/',
+                                             '/usr/share/doc/python-mock-doc/html/objects.inv'))
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
