MCPcopy Index your code
hub / github.com/RustPython/RustPython / _url_handler

Function _url_handler

Lib/pydoc.py:2486–2719  ·  view source on GitHub ↗

The pydoc url handler for use with the pydoc server. If the content_type is 'text/css', the _pydoc.css style sheet is read and returned if it exits. If the content_type is 'text/html', then the result of get_html_page(url) is returned.

(url, content_type="text/html")

Source from the content-addressed store, hash-verified

2484
2485
2486def _url_handler(url, content_type="text/html"):
2487 """The pydoc url handler for use with the pydoc server.
2488
2489 If the content_type is 'text/css', the _pydoc.css style
2490 sheet is read and returned if it exits.
2491
2492 If the content_type is 'text/html', then the result of
2493 get_html_page(url) is returned.
2494 """
2495 class _HTMLDoc(HTMLDoc):
2496
2497 def page(self, title, contents):
2498 """Format an HTML page."""
2499 css_path = "pydoc_data/_pydoc.css"
2500 css_link = (
2501 '<link rel="stylesheet" type="text/css" href="%s">' %
2502 css_path)
2503 return ''&#x27;\
2504<!DOCTYPE>
2505<html lang="en">
2506<head>
2507<meta charset="utf-8">
2508<title>Pydoc: %s</title>
2509%s</head><body>%s<div style="clear:both;padding-top:.5em;">%s</div>
2510</body></html>''&#x27; % (title, css_link, html_navbar(), contents)
2511
2512
2513 html = _HTMLDoc()
2514
2515 def html_navbar():
2516 version = html.escape("%s [%s, %s]" % (platform.python_version(),
2517 platform.python_build()[0],
2518 platform.python_compiler()))
2519 return """
2520 <div style='float:left'>
2521 Python %s<br>%s
2522 </div>
2523 <div style='float:right'>
2524 <div style='text-align:center'>
2525 <a href="index.html">Module Index</a>
2526 : <a href="topics.html">Topics</a>
2527 : <a href="keywords.html">Keywords</a>
2528 </div>
2529 <div>
2530 <form action="get" style='display:inline;'>
2531 <input type=text name=key size=15>
2532 <input type=submit value="Get">
2533 </form>&nbsp;
2534 <form action="search" style='display:inline;'>
2535 <input type=text name=key size=15>
2536 <input type=submit value="Search">
2537 </form>
2538 </div>
2539 </div>
2540 """ % (version, html.escape(platform.platform(terse=True)))
2541
2542 def html_index():
2543 """Module Index page."""

Callers

nothing calls this directly

Calls 7

_HTMLDocClass · 0.85
get_html_pageFunction · 0.85
realpathMethod · 0.80
openFunction · 0.70
startswithMethod · 0.45
joinMethod · 0.45
readlinesMethod · 0.45

Tested by

no test coverage detected