MCPcopy Index your code
hub / github.com/python/cpython / _get_dochome

Function _get_dochome

Lib/idlelib/help.py:297–335  ·  view source on GitHub ↗

Return path to local docs if present, otherwise link to docs.python.org.

()

Source from the content-addressed store, hash-verified

295
296
297def _get_dochome():
298 "Return path to local docs if present, otherwise link to docs.python.org."
299
300 dochome = os.path.join(sys.base_prefix, 'Doc', 'index.html')
301 if sys.platform.count('linux'):
302 # look for html docs in a couple of standard places
303 pyver = 'python-docs-' + '%s.%s.%s' % sys.version_info[:3]
304 if os.path.isdir('/var/www/html/python/'): # rpm package manager
305 dochome = '/var/www/html/python/index.html'
306 else:
307 basepath = '/usr/share/doc/' # dnf/apt package managers
308 dochome = os.path.join(basepath, pyver, 'Doc', 'index.html')
309
310 elif sys.platform[:3] == 'win':
311 import winreg # Windows only, block only executed once.
312 docfile = ''
313 KEY = (rf"Software\Python\PythonCore\{sys.winver}"
314 r"\Help\Main Python Documentation")
315 try:
316 docfile = winreg.QueryValue(winreg.HKEY_CURRENT_USER, KEY)
317 except FileNotFoundError:
318 try:
319 docfile = winreg.QueryValue(winreg.HKEY_LOCAL_MACHINE, KEY)
320 except FileNotFoundError:
321 pass
322 if os.path.isfile(docfile):
323 dochome = docfile
324 elif sys.platform == 'darwin':
325 # documentation may be stored inside a python framework
326 dochome = os.path.join(sys.base_prefix,
327 'Resources/English.lproj/Documentation/index.html')
328 dochome = os.path.normpath(dochome)
329 if os.path.isfile(dochome):
330 if sys.platform == 'darwin':
331 # Safari requires real file:-URLs
332 return 'file://' + dochome
333 return dochome
334 else:
335 return "https://docs.python.org/%d.%d/" % sys.version_info[:2]
336
337
338if __name__ == '__main__':

Callers 1

__init__Method · 0.90

Calls 5

QueryValueMethod · 0.80
joinMethod · 0.45
countMethod · 0.45
isdirMethod · 0.45
isfileMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…